hi i'm new to vb. how can i write to iterate while loop till the end of the string.. can any one help please...

Recommended Answers

All 6 Replies

Please explain in more detail what you want to do because I really don't understand what your saying

If you are reading the characters in a string then

    Dim aChr as String
    Dim X as Integer

    For X = 1 to len(MyString)
            aChr = mid$(MyString,1 ,1)
            'do code
    Next X

If you are reading from a file that will be different.

len function is not working...
its considering it as an array...

thank you......

make it
mid$(achr, X, 1)
that should work better

sir problem is not with mid$
but with len(string)

when i write like that, it shows an error that len not delared

@Klahr_R
Never Forget to increment the value of X. in you case it will always return the same character because start position is not incremented. so don't forget to put X=X+1 after mid$(achr, X, 1)

@baabjitvk
try this

Dim str As String
Dim i As Integer
i = 1
str = "String"
While i <= Len(str)
MsgBox Mid(str, i, 1)
i = i + 1
Wend

hope this helps you . . .

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.