RyanHecht
New member
Hey, I'm 14, and fairly new to vb.net, having started a class in high school a couple weeks ago, and have been learning things as I've been going along. My most recent endeavor is a hangman game. I am designing a function to check whether a letter (guess) is contained in the secret word (HangWord), and then checks for occurrences of that word and replaces it in the form with the guess (lblword is the label it is changing, currently it would have "_" for each blank space (ignore the "DEBUGS", they're for, uh, debugging). The guess processes, and if the guess is correct the first part of the If statement runs. However, lblword.text does not change for the guess. If there are any more details that must be given, let me know and I will provide them. This is my first post on this forum, and I've only been using vb.net for about a month. If you introduce something not in the code currently, please include an explanation about it, so I can learn what it does, instead of blind copy/pasting. Also, I am not looking to change any mechanics of the game too drastically lol. Thanks, hope you guys can help!
Here is the body of the function I am desinging:
Here is the body of the function I am desinging:
VB.NET:
If InStr(HangWord, Guess) Then
DEBUG2.Text = Guess
While counter <= WordLength
If HangWord(counter) = Guess Then
Replace(lblword.Text, Guess, counter, 1)
End If
counter = counter + 1
End While
Else
lblWrong.Text = lblWrong.Text + Guess & " "
misses = misses + 1
If misses = 1 Then
board.Text = " +---+ " & vbCrLf & _
" | |" & vbCrLf & _
" O |" & vbCrLf & _
" |" & vbCrLf & _
" |" & vbCrLf & _
" |" & vbCrLf & _
"========="
ElseIf misses = 2 Then
board.Text = " +---+ " & vbCrLf & _
" | |" & vbCrLf & _
" O |" & vbCrLf & _
" | |" & vbCrLf & _
" |" & vbCrLf & _
" |" & vbCrLf & _
"========="
ElseIf misses = 3 Then
board.Text = " +---+ " & vbCrLf & _
" | |" & vbCrLf & _
" O |" & vbCrLf & _
" /| |" & vbCrLf & _
" |" & vbCrLf & _
" |" & vbCrLf & _
"========="
ElseIf misses = 4 Then
board.Text = " +---+ " & vbCrLf & _
" | |" & vbCrLf & _
" O |" & vbCrLf & _
" /|\ |" & vbCrLf & _
" |" & vbCrLf & _
" |" & vbCrLf & _
"========="
ElseIf misses = 5 Then
board.Text = " +---+ " & vbCrLf & _
" | |" & vbCrLf & _
" O |" & vbCrLf & _
" /|\ |" & vbCrLf & _
" / |" & vbCrLf & _
" |" & vbCrLf & _
"========="
ElseIf misses = 6 Then
board.Text = " +---+ " & vbCrLf & _
" | |" & vbCrLf & _
" O |" & vbCrLf & _
" /|\ |" & vbCrLf & _
" / \ |" & vbCrLf & _
" |" & vbCrLf & _
"========="
lblLose.Visible = True
btnEnd.Visible = True
End If
End If