First off - I'm new at this so I'm sorry up front if I ask - dumb Q's
I'm trying to learn VB 6
Trying to put together a hangman game.
I'm working with a textbox, command button. and some labels as well as a few variables.
Private Sub Form_Load()
Dim Correct As Boolean
Dim x% 'use as counter
Dim SecretWord(8, 2)
'load secret word as an array
SecretWord(1, 1) = "L"
SecretWord(2, 1) = "E"
SecretWord(3, 1) = "A"
SecretWord(4, 1) = "R"
SecretWord(5, 1) = "N"
SecretWord(6, 1) = "K"
SecretWord(7, 1) = "E"
SecretWord(8, 1) = "Y"
For x% = 1 To 8
SecretWord(x, 2) = "*"
Label1.Caption = Label1.Caption & SecretWord(x, 2)
Next
End Sub
Private Sub Command1_Click( )
Dim x%
Static Guesses As Integer
Dim SecretWord(8, 2)
Dim Correct As Boolean
Correct = False
Text1.SetFocus
Text1.SelLength = Len(Text1.Text)
For x = 1 To 8
If Text1.Text = SecretWord(x, 1) Then
SecretWord(x, 2) = SecretWord(x, 1)
Correct = True
End If
Next
If Correct = False Then
Guesses = Guesses + 1
Label2.Caption = Guesses
End If
End Sub
I can't get The correct guesses in the TextBox to appear in the (x,2) of my array
and I can't set focus to my Text1.Text
I'm trying to use a multdemensional array
Thanks, Jim
I'm trying to learn VB 6
Trying to put together a hangman game.
I'm working with a textbox, command button. and some labels as well as a few variables.
Private Sub Form_Load()
Dim Correct As Boolean
Dim x% 'use as counter
Dim SecretWord(8, 2)
'load secret word as an array
SecretWord(1, 1) = "L"
SecretWord(2, 1) = "E"
SecretWord(3, 1) = "A"
SecretWord(4, 1) = "R"
SecretWord(5, 1) = "N"
SecretWord(6, 1) = "K"
SecretWord(7, 1) = "E"
SecretWord(8, 1) = "Y"
For x% = 1 To 8
SecretWord(x, 2) = "*"
Label1.Caption = Label1.Caption & SecretWord(x, 2)
Next
End Sub
Private Sub Command1_Click( )
Dim x%
Static Guesses As Integer
Dim SecretWord(8, 2)
Dim Correct As Boolean
Correct = False
Text1.SetFocus
Text1.SelLength = Len(Text1.Text)
For x = 1 To 8
If Text1.Text = SecretWord(x, 1) Then
SecretWord(x, 2) = SecretWord(x, 1)
Correct = True
End If
Next
If Correct = False Then
Guesses = Guesses + 1
Label2.Caption = Guesses
End If
End Sub
I can't get The correct guesses in the TextBox to appear in the (x,2) of my array
and I can't set focus to my Text1.Text
I'm trying to use a multdemensional array
Thanks, Jim
Comment