| | |
Help with a loop
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Mar 2008
Posts: 10
Reputation:
Solved Threads: 1
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?
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?
•
•
Join Date: Mar 2009
Posts: 907
Reputation:
Solved Threads: 167
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
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
•
•
Join Date: Mar 2008
Posts: 10
Reputation:
Solved Threads: 1
•
•
•
•
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
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
•
•
Join Date: Mar 2009
Posts: 907
Reputation:
Solved Threads: 167
An example of psudo code about the game hangman
http://www.tek-tips.com/viewthread.c...1534972&page=1
http://www.tek-tips.com/viewthread.c...1534972&page=1
![]() |
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: vb Chat App,Lan work Internet Not?
- Next Thread: How to create Subreport in crystal report XI
Views: 320 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 429 2007 access activex add age append application basic beginner birth bmp c++ calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver struct table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





