Okay, let's go back to your original sub. I'll mark in Red the condition you're interested in (whether the words match), Blue the code that should be executed if the condition is true and Green the code that should execute if the condition is false:
And compare that to what an If/Else block should look like:Code:Private Sub btnGuessW_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGuessW.Click Dim strWordGuessed = "BASSETT HOUND" Dim strWordtoGuess = "BASSETT HOUND" strWordGuessed = txtWord.Text() txtWord.Text = strWordGuessed.ToUpper() intNumTries += 1 If strWordGuessed = strWordtoGuess Then MessageBox.Show("BASSETT HOUND") MessageBox.Show("You guessed the word in " & intNumTries & " tries.") End If intNumWrongTries = intNumWrongTries + 1 If intNumWrongTries < 6 Then MessageBox.Show("That is not correct. You have guessed wrong " & intNumWrongTries & " times.") ElseIf intNumWrongTries = 6 Then MessageBox.Show("You lose") lblWord.Text = "Bassett Hound" End If End Sub
Code:If conditionExpression Then ' This code executed if condition true Else ' This code executed if condition false End If




Reply With Quote