Results 1 to 8 of 8

Thread: family feud

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    5

    Exclamation 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

  2. #2
    New Member
    Join Date
    Apr 2005
    Posts
    8

    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.

  3. #3
    Fanatic Member
    Join Date
    Aug 2003
    Posts
    601

    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.

  4. #4

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    5

    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

  5. #5
    New Member
    Join Date
    Apr 2005
    Posts
    8

    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.

  6. #6
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: family feud

    <I moved the thread, since there was no demo in the thread>

  7. #7

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    5

    Re: family feud

    where exactly did you move the thread to?

  8. #8

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    5

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width