This message was edited by the walrus at 2005-2-8 14:59:56
: I wonder if anybody kindly can help me to know how to use the (left,middle,right) function in visual basic 6.0 . basicly i need a function to deal with every charecter in a word on its own, i guess that is the right function, but i do not have its syntax. so if you can help or if u have another easier function for the same operation i will be very greatful. thanks in advance
:
you probably want to use
Mid(String, Position, Length). here's an example:
Dim xStr as String
xStr = Mid$("This is a string", 6, 8)
MsgBox xStr
the output will be "is a str", because it takes the section of the string starting at the 6th character and ending at the 14th (6 + 8) character.
here's an example for processing each character of a string:
Dim xStr as String, yStr as String, i as Long
xStr = "This is a string"
For i = 1 to Len(xStr)
yStr = yStr & Mid(xStr, i, 1) & " "
Next
MsgBox yStr
as you see, this adds a space between each character in xStr and saves it in yStr, so for processing each character in a string, mid is the way to go, but just so you'll know here's how to use Left and Right.
Dim xStr as String
xStr = "This is a string"
MsgBox Left(xStr, 8)
MsgBox Right(xStr, 8)