string checking

G

Guest

Hello.
What is the best way to run through a string character by character ?

Thanks

Luis
 
D

Douglas J. Steele

Dim lngLoop As Long
Dim strText As String

strText = "Test string"

For lngLoop = 1 To Len(strText)
Debug.Print "Position " & lngLoop & " is " & Mid$(strText, lngLoop, 1)
Next lngLoop

will result in

Position 1 is T
Position 2 is e
Position 3 is s
Position 4 is t
Position 5 is
Position 6 is s
Position 7 is t
Position 8 is r
Position 9 is i
Position 10 is n
Position 11 is g
 
G

Guest

Perfect. Thats exactly what i want.

Thanks


Douglas J. Steele said:
Dim lngLoop As Long
Dim strText As String

strText = "Test string"

For lngLoop = 1 To Len(strText)
Debug.Print "Position " & lngLoop & " is " & Mid$(strText, lngLoop, 1)
Next lngLoop

will result in

Position 1 is T
Position 2 is e
Position 3 is s
Position 4 is t
Position 5 is
Position 6 is s
Position 7 is t
Position 8 is r
Position 9 is i
Position 10 is n
Position 11 is g
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Encoding string to UTF-8 1
Format string 2
Space$ error ? 1
Dlookup minimum value 3
Going through a string, a char at a time. 5
"%" character 1
"%" character in string 5
Current Record Number 1

Top