有10个文本框 有一字符串"1 2 3 4 5 6 7 8  9"
text1.text=1
text2.text=1
text3.text=3
...text8.text=8
text9.text=""
text10.text=9这其中每个数字都是用空格分开的 但 8和9之间只有2个空格 所以text9.text=""  (""为空,不是引号)用这个例子就是想说明白这一点 如果是有连续2个空格的话 那么读到那里的那个 text?.text=""  现在有50个文本框 有一字符串"dsa dsf gfg gfd rer dfd  fdsf dfsf erer    fsdfd ...."text1.text=dsa
text2.text=dsf
...
text50.text=..
应该怎么编这个程序谢了。

解决方案 »

  1.   

    dim strTmp() as string
    aa="dsf dfg gfg "
    strTmp = Split(strLine, " ")
    text1.text=strTmp(0)
    text2.text=strTmp(1)
    text3.text=strTmp(2)
      

  2.   

    '添加 text1数组 text(0)到text(9)
    Private Sub Command1_Click()
    Dim str As String
    Dim arr() As String
    Dim i As Long str = "1 5 6  8  9 a d AD" 'text 个数要和字符串数一样
      
     arr = Split(str, " ")
     For i = 0 To UBound(arr)
       Text1(i) = arr(i)
       Next i
       
     
    End Sub
      

  3.   

    '添加 text1控件数组 text1(0) 
    Private Sub Command1_Click() 
    Dim str As String 
    Dim arr() As String 
    Dim i As Long str = ""dsa dsf gfg gfd rer dfd fdsf dfsf erer fsdfd ...."" 'text 个数要和字符串数一样 
      
    arr = Split(str, " ") 
    For i = 0 To UBound(arr) 
      if i <>0 then load text1(i) 
      Text1(i) = arr(i) 
      Next i 
      End Sub 
      

  4.   

    如果你不辞辛苦50个文本text1 text2 text3.....等等都已经摆好,用以下方法:
    Private Sub Command1_Click() 
    Dim str As String 
    Dim arr() As String 
    Dim i As Long 
    dim K as string
    str = ""dsa dsf gfg gfd rer dfd fdsf dfsf erer fsdfd ...."" &apos;text 个数要和字符串数一样 
      
    arr = Split(str, " ") 
    For i = 1 To UBound(arr)+1
        K = "text" & Trim(i)
        Me.Controls(K).Caption = arr(i)
    Next i End Sub 
      

  5.   

    如果你不辞辛苦50个文本text1 text2 text3.....等等都已经摆好,用以下方法: 
    Private Sub Command1_Click() 
    Dim str As String 
    Dim arr() As String 
    Dim i As Long 
    dim K as string 
    str = ""dsa dsf gfg gfd rer dfd fdsf dfsf erer fsdfd ...."" &apos;text 个数要和字符串数一样 
      
    arr = Split(str, " ") 
    For i = 1 To UBound(arr)+1 
        K = "text" & Trim(i) 
        Me.Controls(K).Caption = arr(i-1) 
    Next i End Sub 
      

  6.   

    Private Sub Command1_Click()
    Dim s
    Dim a As Object
    For Each a In Me.Controls
    If TypeOf a Is TextBox Then
    s = Mid(a.Name, 5, Len(a.Name) - 4)
    a.Text = s
    End If
    Next
    End Sub
    Private Sub Command2_Click()
    Dim s
    Dim a As Object
    iStr = "dsa dsf gfg gfd rer dfd fdsf dfsf erer fsdfd "
    s = Split(iStr, " ")
    For Each a In Me.Controls
    If TypeOf a Is TextBox Then
    L = Mid(a.Name, 5, Len(a.Name) - 4)
    a.Text = s(L - 1)
    End If
    Next
    End Sub