Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Help making a program on Visual Basic
Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
CompN




PostPosted: Sat Oct 28, 2006 3:07 pm   Post subject: 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.
Sponsor
Sponsor
Sponsor
sponsor
Silent Avenger




PostPosted: Sat Oct 28, 2006 7:58 pm   Post subject: (No subject)

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




PostPosted: Sun Oct 29, 2006 11:11 am   Post subject: (No subject)

Silent Avenger wrote:
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


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. Smile
raptors892004




PostPosted: Sun Oct 29, 2006 11:30 am   Post subject: (No subject)

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 Smile
raptors892004




PostPosted: Sun Oct 29, 2006 11:32 am   Post subject: (No subject)

cool dude wrote:
Silent Avenger wrote:
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


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. Smile


I didn't see this before writing my post. Now you've got two solutions Very Happy
Numbah51




PostPosted: Thu Nov 30, 2006 7:57 pm   Post subject: (No subject)

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




PostPosted: Thu Nov 30, 2006 8:57 pm   Post subject: (No subject)

Numbah51 wrote:
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.
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: