none
Name Formatting RRS feed

  • Question

  • Hey! I'm trying to make a program that when you enter in you name lastname,firstname it will switch the places of the names and remove the comma. I could really use some help ASAP

    • Edited by AsherBeane Tuesday, March 13, 2018 12:00 AM
    Monday, March 12, 2018 11:58 PM

All replies

  • Hi

    Here is one way. Assuming TextBox1.Text contains LastName, FirstName, then if you put this code in a Button Click event it will reverse the names.

    	Dim a() As String = Split(TextBox1.Text, ",")
    	' if you do not want the comma in the new text then 
    	' remove from the ", " -, you probably do want the space.
    	TextBox1.Text = Trim(a(1)) & ", " & Trim(a(0))
    


    Regards Les, Livingston, Scotland

    • Proposed as answer by Cor Ligthert Tuesday, March 13, 2018 12:43 AM
    Tuesday, March 13, 2018 12:09 AM
  • Thank you! this helps a lot! how would I then have the results be put into a Label ?

    Tuesday, March 13, 2018 12:16 AM
  • Hi

    Well, suppose you had Label1 on the Form, then substitute Label1 for TextBox1 in the second code line I posted.


    Regards Les, Livingston, Scotland

    Tuesday, March 13, 2018 12:18 AM
  • Thank you so much! I was so lost on how to do this! this solves it!
    Tuesday, March 13, 2018 12:22 AM
  • Hi AsherBeane,

    If your issue has been solved, please remember to close your thread by marking the helpful post as answer, it is beneficial to other communities who face the same issue.

    Thanks for your understanding.

    Best Regards,

    Cherry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, March 13, 2018 7:59 AM
    Moderator