text1里有字符串如下:
3d3
44
55
dd
25r5
我想分成一行行,存到一个字符串数组toola()里面如下
toola(0)=3d3
toola(1)=44
toola(2)=55
.....下面是我的代码
Private Sub Command1_Click()
Dim i As Integer: Dim cr_n As Integer: Dim str_len As Integer
Dim str_tool As String
Dim toola(100) As String
    str_tool = Text1.Text
    str_len = Len(str_tool)
    For i = 0 To 100 Step 1
       cr_n = InStr(1, str_tool, Chr(13))
        If cr_n = str_len - cr_n Then
        Exit For
        End If
       toola(i) = Mid(str_tool, 1, str_len - cr_n)
       str_tool = Mid(str_tool, str_len - cr_n, str_len)
      Next i
Text2.Text = toola(1)   
End Sub大侠们帮忙解决一下,小弟不胜感激

解决方案 »

  1.   

    要看是用什么分割的。换行或者空格,可用split函数直接转
      

  2.   

    toola = Split(textBox1.Text, VbCrLf)
      

  3.   

    Private Sub Command1_Click()
    Dim toola(100) As String
    toola = Split(textBox1.Text, vbCrLf)
    Text2.Text = toola(1)
    End Sub
    感谢上面两位的回复
    改成这样,运行报错,不能给数组赋值
      

  4.   

    Dim toola(100) As String
    =>
    Dim toola() As String
      

  5.   

    dim s as string 
    dim total() as string
    s=text1total=split(s,vbcrlf)dim i as long
    for i=0 to ubound(total)
    debug.print total(i)
    next
      

  6.   

    Private Sub Command1_Click()
    Dim toola() As String
    toola = Split(Text1.Text, vbCrLf)
    Text2.Text = toola(1)
    End Sub
    这样可用了,就是引用时下标不超过数组大小就行了
    差不多了,下边我找找方法再试试
      

  7.   

    你可以判断下
    UBound(toola)可以返回最大的下标。