• We just launched and are currently in beta. Join us as we build and grow the community.

Reverse a String in VB6

Javilon06

Fandom Organizer
J Rep
0
0
0
Rep
0
J Vouches
0
0
0
Vouches
0
Posts
73
Likes
64
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 200 XP
Hi! In this tutorial, we will create a program that reverses a string. I already made this one in vb.net 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:

reversedesign.png


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

    Sub

    Command1_Click()

  2. Dim

    lLen As

    Integer

    , lCtr As

    Integer
  3. Dim

    sChar As

    String
  4. Dim

    sAns As

    String

  5. lLen = Len(Text1.Text)
  6. For

    lCtr = lLen To

    1 Step

    -1
  7. sChar = Mid(Text1.Text, lCtr, 1)
  8. sAns = sAns & sChar
  9. Next

  10. Label1.Caption = sAns

  11. End

    Sub

Explanation:

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.

Output:

reverseoutput.png


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: https://www.facebook.com/donzzsky

Visit and like my page on Facebook at: https://www.facebook.com/BermzISware


Download
You must upgrade your account or reply in the thread to view hidden text.
 

452,292

323,341

323,350

Top