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?

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.