我想在文本框中输入一不定长数列,以逗号隔开,文本框中只能有数字后逗号,然后逐个剪切存在一数组里,但是出现了问题。Private Sub Text4_KeyDown(KeyCode As Integer, Shift As Integer)这个函数不接收逗号(逗号用的是ASCII码44)请问各位还有其他什么方法?

解决方案 »

  1.   

    Private Sub Text1_KeyPress(KeyAscii As Integer)
        Select Case KeyAscii
           Case Is < Asc("0")
              If KeyAscii <> 44 Then KeyAscii = 0
           Case Is > Asc("9")
              KeyAscii = 0
        End Select
      
    End SubBest regards!
    Shannon shang [Microsoft VB MVP]
    bLog:http://www.msmvps.com/ch21st/
      

  2.   

    Option Explicit
    Dim x() As String
    Private Sub Command1_Click()
        Dim i%
        x = Split(Text1.Text, ",")
        For i = 0 To UBound(x)
            Print x(i),
        Next i
    End SubPrivate Sub Text1_KeyPress(KeyAscii As Integer)
        Dim c As String * 1
        c = Chr(KeyAscii)
        If InStr(",0123456789", c) = 0 And KeyAscii <> 8 Then
            KeyAscii = 0
        End If
    End Sub