PDA

View Full Version : Reverse a String in Visual Basic


lamlamlamiaaa
Apr 12, 2012, 05:18 PM
I want to make a program where the user enters a word and it will come out backwards.
For Example:
Basic -> cisaB

Please and Thank you!

ScottGem
Apr 12, 2012, 05:22 PM
Use a For... Next loop to loop for the length of the string. With each pass of the loop Use the Right() function to grab the last character and add it to a new string. Then use the Left() function to replace the string with the remaining characters.

lamlamlamiaaa
Apr 13, 2012, 06:29 AM
Can you explain a bit more how to use the Right() and Left() function?

ScottGem
Apr 13, 2012, 08:08 AM
I'm assuming this is a homework question. That's why I didn't show you a code sample. I just gave you enough direction to find the answer. There are plenty of VB resources that explain how to use the Right and Left functions and Loops that you can look up.