在TEXT1(0)-TEXT1(17)都限制1字符然后输入1,2,3-17 那么RichTextBox里就显示1,2,3-17 
希望输入结束后光标能直接从TEXT1(0)重新开始输入 并且 当我再次输入其他如(A,B,C-Q)时RichTextBox里能保留历史输入的数据 并换行输入新的

解决方案 »

  1.   

    你把源文件发给我,我给你改
    [email protected]
      

  2.   

    你这样做法会有很多弊端,我假设你是在特殊状态下使用Dim intRowCount As Integer
    Dim strTemp As String
    Dim strRTB As StringPrivate Sub Form_Load()
        Dim i As Integer
        
        For i = 0 To Text1.UBound
            Text1(i).MaxLength = 1
        Next i
        
    End SubPrivate Sub Text1_Change(Index As Integer)
        Dim i As Integer    If Len(Text1(Index).Text) = Text1(Index).MaxLength Then
            If Len(strTemp) >= Index + 1 Then
                Mid(strTemp, Index + 1, 1) = Text1(Index).Text
            Else
                strTemp = strTemp & Text1(Index).Text
            End If        If Index = Text1.UBound Then
                For i = 0 To Text1.UBound
                    Text1(i).Text = ""
                Next i            strRTB = strRTB & strTemp & Chr(13)
                strTemp = ""
                intRowCount = intRowCount + 1
                Text1(0).SetFocus
            Else
                Text1(Index + 1).SetFocus
            End If
            
            RichTextBox1.Text = strRTB & strTemp
        End If    
    End Sub
      

  3.   

    我用3个text测试abc
    def
    ghi
    jkl
    mn
      

  4.   


    Private Sub Text1_GotFocus(Index As Integer)
        Text1(Index).SelStart = 0
        Text1(Index).SelLength = 1
    End SubPrivate Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
        RichTextBox1.Text = RichTextBox1.Text & Chr(KeyAscii)
        RichTextBox1.Refresh
        
        If Index = Text1.UBound Then
            RichTextBox1.Text = RichTextBox1.Text & vbCrLf
            Text1(0).SetFocus
        Else
            Text1(Index + 1).SetFocus
        End If
    End Sub
      

  5.   

    呵呵    Text1(Index).SelStart = 0 
        Text1(Index).SelLength = 1 
    还有这个功效