VB中 5个TEST 控件 在第1个输入例如: 12345 那么第一个只显示1 第2个中只显示2 依次类推 请问如何编写?

解决方案 »

  1.   

    str=text(0).text
    for i=0 to 4
       text(i).text=mid(str,i,1)
    next
      

  2.   

    输入几个数字或字母后 每个TEST中限定只显示1字符 
    在 Private Sub Text1_Change(Index As Integer)下面如何编写
      

  3.   

    mid(string,start as integer,length as integer)
      

  4.   

    Private Sub Text1_Change(Index As Integer)
    Select Case Index
    Case 0
    If Text1(0).Text = "12345" Then
    For I = 0 To 4
    Text1(I).Text = I + 1
    Next
    End If
    End Select
    End Sub
      

  5.   

    或者:
    Text1(I).Text = mid(TEXT1(0).TEXT,i,1) 
      

  6.   

    不是只输入12345 我只是随便举个例子 运行后的效果是 在第1个TEST里输入几个数字或字母 那么会1个1个的在TEST1 ,2, 3....显示出来 比如说: 输入a1b2  那么TEST1=a  TEST2=1 TEST3=b TEST4=2 依次类推  
      

  7.   

    Private Sub Command1_Click()
        Dim a As TextBox
        Dim j As Integer
        Dim i As Integer
        Dim m As String
        i = Len(Text1.Text)
        m = Text1.Text
        For j = 1 To i
            Set a = Form1.Controls.Add("VB.TextBox", "TextBox" & j)
            a.Visible = True
            a.Move j * 500, j * 400, 1000, 300
            a.Text = Mid(m, j, 1)
        Next
    End Sub
    不知道符不符合你的要求,不过大体意思应该是这样子的吧。
      

  8.   

    Private Sub Text1_Change(Index As Integer)这个下怎么编
      

  9.   

    控件数组 Text1(0) ~ Text1(4):Private Sub Form_Load()
    Dim i As Integer
        For i = 0 To 4
            Text1(i).MaxLength = 1
        Next i
    End SubPrivate Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
        If (Index < 4) Then
            Text1(Index + 1).SetFocus
        End If
    End Sub
      

  10.   

    上面最好添上代码:
    Private Sub Text1_GotFocus(Index As Integer)
        Text1(Index) = ""
    End Sub如果一定要 Text1 至 Text5:Private Sub Form_Load()
        Text1.MaxLength = 1
        Text2.MaxLength = 1
        Text3.MaxLength = 1
        Text4.MaxLength = 1
        Text5.MaxLength = 1
    End SubPrivate Sub Text1_KeyPress(KeyAscii As Integer) 
        Text2.SetFocus 
    End Sub Private Sub Text2_KeyPress(KeyAscii As Integer) 
        Text3.SetFocus 
    End Sub Private Sub Text3_KeyPress(KeyAscii As Integer) 
        Text4.SetFocus 
    End Sub Private Sub Text4_KeyPress(KeyAscii As Integer) 
        Text5.SetFocus 
    End Sub Private Sub Text1_GotFocus()
        Text1 = ""
    End SubPrivate Sub Text2_GotFocus()
        Text2 = ""
    End SubPrivate Sub Text3_GotFocus()
        Text3 = ""
    End SubPrivate Sub Text4_GotFocus()
        Text4 = ""
    End SubPrivate Sub Text5_GotFocus()
        Text5 = ""
    End Sub