I am having a problem on how to count numbers inside text area. . .

example: In my text area I have 10 numbers.

12, 06, 31, 22, 53, 28, 96, 71, 10, 47

the the program should count how many 0,1,2,3,4....9 excluding the comma. I don't know how to do this inside a text area or a multiline text box. Can anyone help me or give an example or idea on how to do this. . . .please.

try this:

Sub xx()
    Dim txt As String
    Dim x As Variant
    Dim i As Long
    txt = "10,11,12,13,14,15,16,17,18,1,2,3,4"
    x = Split(txt, ",")
    For i = 0 To UBound(x): Next i
    MsgBox "There are " & i & " numbers in your text area"
End Sub

try this:

Sub xx()
    Dim txt As String
    Dim x As Variant
    Dim i As Long
    txt = "10,11,12,13,14,15,16,17,18,1,2,3,4"
    x = Split(txt, ",")
    For i = 0 To UBound(x): Next i
    MsgBox "There are " & i & " numbers in your text area"
End Sub

Ahhh....

Why not just use ubound+1?

Sub xx()
    Dim txt As String
    Dim x As Variant
    Dim i As Long
    txt = "10,11,12,13,14,15,16,17,18,1,2,3,4"
    x = Split(txt, ",")
    MsgBox "There are " & UBound(x) + 1 & " numbers in your text area"
End Sub

Good Luck

Hmm..that's really better.. :)

thank you so much it is solved. . .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.