-
family feud
I am trying to create a small family feud game with vb 6.0. Can anyone help try to make this snippet of the code work. The purpose is to check to see if the string in text matches if it doesn't you have 3 chances to get the correct answer. Once count is = to 3 then it should tell you that you have lost. For some reason it is not working. Any help would greatly be appreciated. :)
Do While count <> 3
If Text1 = "cat" Then
resp = MsgBox("yeah", vbInformation)
Else
resp2 = MsgBox("try again", vbOKOnly)
count = count + 1
Text1 = ""
End If
Loop
If count = 3 Then resp3 = MsgBox("lose", vbOKCancel)
End Sub
-
Re: family feud
remove Text1 = "" from your Do While loop, it's not needed.
After the Loop use If count >= 3 ...
Not sure if that'll solve your problem, but it'll make for better code.
-
Re: family feud
i dont think you should use a loop. it will not giver a user time to type. it will just pop up 3 message box's right away.
-
Re: family feud
if i don't use a loop How would i count how many times they entered a wrong answer before losing the game
-
Re: family feud
Using a loop is fine, just in your loop there is no code to take input from the user, so in this example it would immediately execute the loop 3 times.
-
Re: family feud
<I moved the thread, since there was no demo in the thread>
-
Re: family feud
where exactly did you move the thread to?
-
Re: family feud
I think i found the solution. Take a look at this snippet and let me know what you think
If txtAnswer1.Text = "cat" Then
num1 = 28
lblAnswer1 = num1
retval = PlaySound("C:\gong.wav", 1)
ElseIf txtAnswer1.Text <> "cat" Then
Do While count <> 3
txtAnswer1.Text = InputBox("PLEASE RE-ENTER ANSWER")
retval1 = PlaySound("C:\buzzer.wav", 1)
count = count + 1
MsgBox (count)
Loop