CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2006
    Posts
    2

    how do u switch names places? i.e. typing in first/last name, and display backwards

    i can't figure this code out, supposed to type in a name like George Washington, and have it appear in a label, Washington, George

    it has to have the comma and a space between comma and first name, thanks!
    Last edited by adamm104; March 1st, 2006 at 03:33 PM.

  2. #2
    Join Date
    Jan 2006
    Posts
    293

    Re: can u check this code please? i can't get it to work!

    Just a simple exercise in string manipulation....

    One way is to just split the string on the Space character, into an array of strings. Then for the output, concatenate the 1 index of the array (lastname) with a comma and a space, then the 0 index of the array (first name)....

    Another way is to just use .IndexOf on the space character, to get the position, then use that and .SubString in order to get the two parts of the string, then switch them seperated with a command and a space when you build the output string....
    Last edited by gigemboy; March 1st, 2006 at 04:06 PM.

  3. #3
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: can u check this code please? i can't get it to work!

    Here's a list of all String Manipulation functions, they will come in very handy someday!
    http://msdn2.microsoft.com/en-us/library/e3s99sd8.aspx

    PS: Please edit your thread title to something more descriptive

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured