String Manipulation

How do I break a users input into smaller segments to where the text string can be manipulated into seperate variables. I know this is based on the space character, but I just can't figure out how to get this to happen. Please look at my example and provide the code to get this to work. I would truly appreciate it.

My example:

The end user inputs their FirstName LastName within the text box in the exact order as shown. I need to manipulate this string of text to get it to display in the following format, which includes the comma:

LastName, FirstName

How do I get this to work?

Comments

  • : How do I break a users input into smaller segments to where the text string can be manipulated into seperate variables. I know this is based on the space character, but I just can't figure out how to get this to happen. Please look at my example and provide the code to get this to work. I would truly appreciate it.
    :
    : My example:
    :
    : The end user inputs their FirstName LastName within the text box in the exact order as shown. I need to manipulate this string of text to get it to display in the following format, which includes the comma:
    :
    : LastName, FirstName
    :
    : How do I get this to work?
    :

    Something to this effect:

    [code]
    Dim strString As String
    strString = "YOUR NAME"
    Dim strSplit() As String
    strSplit = strString.Split(" "c) 'the 'c' is there ON PURPOSE to
    'specify a character literal..
    'not a mistype

    MsgBox(strSplit(1) & ", " & strSplit(0))
    [/code]


    The Split() function will split a string using a specified separator character into an array.

    This can be useful for parsing comma delimited data.
    line in MyFile.csv = "This,data,is,comma,delimited"
    [code]
    strDataArray = strLineFromFile.Split(","c)
    [/code]

    strDataArray(0) = "This"
    strDataArray(1) = "data"
    strDataArray(2) = "is"
    strDataArray(3) = "comma"
    strDataArray(4) = "delimited"


    --Nips




Sign In or Register to comment.

Howdy, Stranger!

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

Categories

In this Discussion