Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class frmMain
- Public Const ANSWER As String = "somers123"
- Public attempts As Integer
- Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- lblMsg.Text = ""
- attempts = 0
- End Sub
- Private Sub btnSubmit_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click
- Dim guess As String
- 'get guess from screen
- guess = txtPassword.Text
- 'check the guess
- If guess = ANSWER Then
- frmResult.Show()
- Me.Hide()
- frmResult.picResult.Image = My.Resources.success
- Else
- attempts = attempts + 1
- lblMsg.Text = "You have used " & attempts & " attempts out of 3."
- If attempts = 3 Then
- frmResult.Show()
- Me.Hide()
- frmResult.picResult.Image = My.Resources.failure
- End If
- End If
- End Sub
- Private Sub txtPassword_TextChanged(sender As Object, e As EventArgs) Handles txtPassword.TextChanged
- If txtPassword.Text = "" Then
- btnSubmit.Enabled = False
- Else
- btnSubmit.Enabled = True
- End If
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement