
-----------------------------------
CompN
Sat Oct 28, 2006 3:07 pm

Help making a program on Visual Basic
-----------------------------------
Well I need help making a program.  The user has to enter a word and then the program has to display it backwards . I have to use the FOR loop.
So far I have:

Private Sub Seven_Click()
Dim userWord As String
Dim count As Integer
userWord = InputBox("Please enter a word")

    Print Mid(userWord, 3, 1)

    

End Sub

I'm pretty much stuck. Any help would appreciated.

-----------------------------------
Silent Avenger
Sat Oct 28, 2006 7:58 pm


-----------------------------------
Well I used to know how to do this but I haven't used it in about 2 1/2 years so I'm not quite sure on how to do it anymore. You might want to check out cool dude's tutorial and I think what you're looking for might be on day 4 of his tutorial. http://www.compsci.ca/v2/viewtopic.php?t=13107

-----------------------------------
cool dude
Sun Oct 29, 2006 11:11 am


-----------------------------------
Well I used to know how to do this but I haven't used it in about 2 1/2 years so I'm not quite sure on how to do it anymore. You might want to check out cool dude's tutorial and I think what you're looking for might be on day 4 of his tutorial. 

thanks avenger for directing him to my tutorial. i already helped him (through private message) and he uderstands how to do it now as he said.  if he wants to post all the information i gave him he can, because i didn't save it myself and i don't feel like retyping.  :)

-----------------------------------
raptors892004
Sun Oct 29, 2006 11:30 am


-----------------------------------
To start you off on the program, you have to get the word's length. The method for that is:

length = Len(word)

Then the for loop goes from Len(word) - which is the last position of the word to 1 Step -1. So you would declare it like this:

For x = length To 1 Step -1
    output = output & Mid(word, x, 1)
Next x

This for loop will run backwards and add the current letter in the word to a String variable output so it can be later printed onto the form in one line:

Form1.print(output)

Basically how it runs is:

If word had 5 letters:
1st run of for loop
Add to output letter at 5th position in the word
2nd run of loop
Add to output letter at 4th position in the word

And so on until it adds the letter at the 1st position in the word after which the loop exits and you can then display the reversed word to the user. Hope this helps :)

-----------------------------------
raptors892004
Sun Oct 29, 2006 11:32 am


-----------------------------------
Well I used to know how to do this but I haven't used it in about 2 1/2 years so I'm not quite sure on how to do it anymore. You might want to check out cool dude's tutorial and I think what you're looking for might be on day 4 of his tutorial. 

thanks avenger for directing him to my tutorial. i already helped him (through private message) and he uderstands how to do it now as he said.  if he wants to post all the information i gave him he can, because i didn't save it myself and i don't feel like retyping.  :)

I didn't see this before writing my post. Now you've got two solutions :D

-----------------------------------
Numbah51
Thu Nov 30, 2006 7:57 pm


-----------------------------------
Actually there is a very easy way to do this (Sorry, I know the author has already found their answer, but...)

Reversed=StrReverse(UserWord)

-----------------------------------
cool dude
Thu Nov 30, 2006 8:57 pm


-----------------------------------
Actually there is a very easy way to do this (Sorry, I know the author has already found their answer, but...)

Reversed=StrReverse(UserWord)

I was aware of this built in function. The thing is i know if i ever did that my teacher would automatically fail me on this program. As well its a really easy program and it is better to understand how to do it and enhance your skills in VB than to just use a built in function.
