Computer Science Canada Hangmen Game Help |
Author: | Dragoon [ Mon Jun 02, 2003 7:33 pm ] | ||
Post subject: | Hangmen Game Help | ||
Iam having trouble getting my hangmen game to work. I want it to output a message box that says "Head" the first time when the user gets a answer wrong then "Body" if they get the second answer wrong and so on.
|
Author: | MysticAngel [ Mon Jun 02, 2003 8:33 pm ] |
Post subject: | |
k i dont know how u frame the code for wat u asked but u there were a few error in ur program. When u call an object just as text box or a label dont forget to put its type. and for the "For " statements u got to declare the "I". here is the corrected code. As for what u wanted., just draw using the present shapes in VB make them invisible and then in ur code just say like circle. Visible every time the user gets it wrong Option Explicit Dim choice1(0 To 4) As String Dim Word As String Dim Letter As String Dim counter As Integer Private Sub cmdGuess_Click() Dim i As Integer For i = 1 To Len(Word) Letter = Mid(Word, i, 1) Call Check Next i lblPicked.Caption = lblPicked.Caption & txtLetter.Text & "," If counter = Len(Word) Then MsgBox "You guessed all the letters" End If End Sub Private Sub Check() If Letter = txtLetter.Text Then MsgBox Letter & " " & "is in the word" lblRight.Caption = lblRight.Caption & txtLetter & "," counter = counter + 1 End If End Sub Private Sub Form_Load() choice1(0) = "cat" choice1(1) = "dog" choice1(2) = "mouse" choice1(3) = "rat" choice1(4) = "toronto" Randomize Word = choice1(Int(Rnd * 5)) 'Randomizes counter = 0 If Word = "cat" Then lblCat.Caption = "Animal" lblLetters.Caption = "3 Letters" End If If Word = "dog" Then lblCat.Caption = "Animal" lblLetters.Caption = "3 Letters" End If If Word = "mouse" Then lblCat.Caption = "Animal" lblLetters.Caption = "5 Letters" End If If Word = "rat" Then lblCat.Caption = "Animal" lblLetters.Caption = "3 Letters" End If If Word = "toronto" Then lblCat.Caption = "Place" lblLetters.Caption = "7 Letters" End If End Sub |
Author: | G.I._Jane [ Mon Feb 23, 2004 1:17 pm ] |
Post subject: | |
you don't know how to work hang man well I don't either |
Author: | Acid [ Tue Feb 24, 2004 11:01 am ] |
Post subject: | |
what do the Len and Mid commands do? |
Author: | rdrake [ Wed Feb 25, 2004 12:16 pm ] |
Post subject: | |
The Len() command finds the length of the string. The Mid() command returns only a specified number of characters in a string. |