Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How to use the (left,right,middle) functions in visual basic 6

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

Comments

  • the walrusthe walrus Posts: 249Member
    [b][red]This message was edited by the walrus at 2005-2-8 14:59:56[/red][/b][hr]
    : 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 [b]Mid([/b][italic]String[/italic][b],[/b] [italic]Position[/italic][b],[/b] [italic]Length[/italic][b])[/b]. here's an example:

    [code]
    Dim xStr as String

    xStr = Mid$("This is a string", 6, 8)
    MsgBox xStr
    [/code]

    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:

    [code]
    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
    [/code]

    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.

    [code]
    Dim xStr as String

    xStr = "This is a string"
    MsgBox Left(xStr, 8)
    MsgBox Right(xStr, 8)
    [/code]


  • mostafakamarmostafakamar Posts: 15Member
    I will check my self and thank you for helping me.
Sign In or Register to comment.