Help with a loop

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Mar 2008
Posts: 10
Reputation: thando is an unknown quantity at this point 
Solved Threads: 1
thando thando is offline Offline
Newbie Poster

Help with a loop

 
0
  #1
Mar 16th, 2009
im making a hangman project in vb6 and i need some serious help with it!

my prob is with my loop which is having issues -

this is my code:

Dim guess As String, x As Integer, word As String
word = wordBank(stage)
guess = Text1.Text
For x = 1 To Len(word)
If guess = Mid(word, x, 1) Then
Label1.Caption = "yes"
Else
Label1.Caption = "no"
End If
Next x

my loop only seems to recognise the last letter in my word. help?
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 907
Reputation: vb5prgrmr will become famous soon enough vb5prgrmr will become famous soon enough 
Solved Threads: 167
vb5prgrmr vb5prgrmr is offline Offline
Posting Shark

Re: Help with a loop

 
0
  #2
Mar 16th, 2009
Well, I can tell you why. You are going from the first character to the last character and not stopping on either yes or no, so what you are seeing as the loop ends, it the last test on the last letter.

Look up InStr and the Do Loop structure.

It also looks like you are still in the testing stage. Do you know what psuedo code is? If you do, please post your general logic and a description of your design.

Good Luck
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 10
Reputation: thando is an unknown quantity at this point 
Solved Threads: 1
thando thando is offline Offline
Newbie Poster

Re: Help with a loop

 
0
  #3
Mar 16th, 2009
Originally Posted by vb5prgrmr View Post
Well, I can tell you why. You are going from the first character to the last character and not stopping on either yes or no, so what you are seeing as the loop ends, it the last test on the last letter.

Look up InStr and the Do Loop structure.

It also looks like you are still in the testing stage. Do you know what psuedo code is? If you do, please post your general logic and a description of your design.

Good Luck
Hi! ok i'm a real beginner and i have no idea what pseudo code is but i did try and look it up -

however i did as you said - to look up do loop and inStr but i'm still a little confused about how i can use it.

do you think you could give me a realli basic reference on how to do a do loop, cuz all the ones ive been looking at make no sense to me?

id realli appreciate it
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 907
Reputation: vb5prgrmr will become famous soon enough vb5prgrmr will become famous soon enough 
Solved Threads: 167
vb5prgrmr vb5prgrmr is offline Offline
Posting Shark

Re: Help with a loop

 
0
  #4
Mar 16th, 2009
An example of psudo code about the game hangman
http://www.tek-tips.com/viewthread.c...1534972&page=1
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Visual Basic 4 / 5 / 6 Forum


Views: 320 | Replies: 3
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC