DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Visual Basic 4 / 5 / 6 (http://www.daniweb.com/forums/forum4.html)
-   -   Counting Numbers inside text area (http://www.daniweb.com/forums/thread201936.html)

nagatron Jul 6th, 2009 7:33 am
Counting Numbers inside text area
 
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.

cguan_77 Jul 6th, 2009 10:21 am
Re: Counting Numbers inside text area
 
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

vb5prgrmr Jul 6th, 2009 11:12 pm
Re: Counting Numbers inside text area
 
Quote:

Originally Posted by cguan_77 (Post 909678)
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

cguan_77 Jul 7th, 2009 12:59 am
Re: Counting Numbers inside text area
 
Hmm..that's really better.. :)

nagatron Jul 7th, 2009 1:03 pm
Re: Counting Numbers inside text area
 
thank you so much it is solved. . .


All times are GMT -4. The time now is 9:10 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC