比如:我在文本框中输入了13584214,我怎么依次获得每个数字并存入一个数组的各个元素中呢?另外,每次输入的字符的个数不是固定的。谢谢,请赐教

解决方案 »

  1.   

    for i =0 to len(text1.text)-1
        msgbox mid(text1.text,i+1,1)
    next
      

  2.   

    Private Sub Command1_Click()
        Dim i As Integer
        Dim iA() As Integer
        ReDim iA(Len(Text1))
        For i = 1 To Len(Text1)
            If IsNumeric(Mid(Text1, i, 1)) Then
                iA(i) = CInt(Mid(Text1, i, 1))
                Debug.Print iA(i)
            End If
        Next
    End Sub
      

  3.   

    str=text1.text
    for i=1 to len(str)
       chr=mid(str,1,1)
       str=right(str,len(str)-1)
    next i
      

  4.   

    Dim arr() as string
    Private Sub Command1_Click()
    Dim i As Long
    Dim j As Long
    ReDim arr(Len(Text1.Text))
    For i = 0 To Len(Text1.Text) - 1
        arr(i) = Mid(Text1.Text, i + 1, 1)
    Next
     
    For j = 0 To UBound(arr) - 1
        MsgBox arr(j)
        Next
    End Sub
      

  5.   

    Option Explicit
    Dim j() As IntegerPrivate Sub Command1_Click()
    Dim S As String
    Dim i As Integer
    S = Text1.Text
    If Not IsNumeric(S) Then Exit Sub
    ReDim j(Len(S))
    For i = 1 To Len(S)
    j(i) = Mid(S, i, 1)
    Debug.Print j(i)
    Next
    End Sub