Skip to main content

Reverse a String in VB6

Hi! In this tutorial, we will create a program that reverses a string. I already made this one in but it has different code in vb6.0.

Now, let's start this tutorial!

1.Let's start this tutorial by following the following steps in Microsoft Visual Basic 6.0: Open Microsoft Visual Basic 6.0, click Choose Standard EXE, and click Open.

2. Next, add only one Button named Command1 and labeled it as "Reverse". Add one TextBox named Text1 for your input and also one Label named Label1 that will serve to display your output.You must design your interface like this:


3.Now put this code for your code module. This code is for Command1_Click:

  1. Private Sub Command1_Click()
  3. Dim lLen As Integer, lCtr As Integer
  4. Dim sChar As String
  5. Dim sAns As String
  7. lLen = Len(Text1.Text)
  8. For lCtr = lLen To 1 Step -1
  9. sChar = Mid(Text1.Text, lCtr, 1)
  10. sAns = sAns & sChar
  11. Next
  13. Label1.Caption = sAns
  15. End Sub


We initialized lLen as Integer to hold the length of the text inputted in Text1. Len function returns an integer containing either the number of characters in a string or the nominal number of bytes required to store a variable. Then we have created a For Next loop that the lCtr variable will hold the value of variable lLen up to 1 Step -1. Step specifies an increment value for a loop counter. sChar variable was used to get the middle of Text1, the start of the mid which is lCtr and 1 as the length. Mid Function returns a string containing a specified number of characters from a string. Then sAns variable will hold the value of our variable sChar and will be displayed in Label1.



Download the source code and try it! :)

For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below.

Best Regards,

Engr. Lyndon Bermoy
IT Instructor/System Developer/Android Developer/Freelance Programmer
Mobile: 09488225971
Landline: 826-9296
E-mail:[email protected]

Add and Follow me on Facebook:

Visit and like my page on Facebook at:

Visit my website at:

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.


1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

Add new comment

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.