Public Class Form1
Public Contador As Integer
Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click
Label2.Text = Math.Truncate(Rnd(100) * 50 + 1)
Contador = 5
Label1.Text = Contador
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If Contador > 0 Then
If TextBox1.Text = Label2.Text Then
MsgBox("Felicidades, has adivinado el numero, tenias " & Contador & " intento(s) restante(s)", MsgBoxStyle.Information, "Ganaste")
End
Else
Contador = Contador - 1
Label1.Text = Contador
MsgBox("Sigue intentando tienes " & Contador & " Inteno(s) Restante(s)", MsgBoxStyle.Critical, "Fallaste")
End If
Else
MsgBox("Perdiste", MsgBoxStyle.Critical, "Fallaste")
End If
End Sub
End Class