如何实现在TEXT中每输入5个子,便自动换行。

解决方案 »

  1.   

    Private Sub Text1_Change()
    If (Len(Text1.Text) = 5) Then
     Text1.Text = Text1.Text + vbCrLf
     Text1.SelStart = Len(Text1.Text)
     
    End If
    End Sub
      

  2.   

    Option Explicit
    Dim i As IntegerPrivate Sub Form_Load()
    i = 1
    End SubPrivate Sub Text1_KeyPress(KeyAscii As Integer)
    If i > 4 Then
       SendKeys "{enter}"
       i = 0
    Else
       i = i + 1
    End If
    End Sub
      

  3.   

    Private Sub Text1_Change()
    If Text1.Text <> "" Then
    Dim a() As String
    a = Split(Text1.Text, vbCrLf)
    Debug.Print UBound(a)
    If Len(a(UBound(a))) > 5 Then
    SendKeys "~"
    End If
    End If
    End Sub有一点不好的就是,如果是修改前面的字就没反映了。
    这个判断的是最后一行。