Advertisement
ssoni

password.vb

Mar 9th, 2022
1,660
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.22 KB | None | 0 0
  1. Public Class frmMain
  2.  
  3.     Public Const ANSWER As String = "somers123"
  4.     Public attempts As Integer
  5.  
  6.     Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  7.         lblMsg.Text = ""
  8.         attempts = 0
  9.     End Sub
  10.  
  11.     Private Sub btnSubmit_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click
  12.         Dim guess As String
  13.  
  14.         'get guess from screen
  15.         guess = txtPassword.Text
  16.  
  17.         'check the guess
  18.         If guess = ANSWER Then
  19.             frmResult.Show()
  20.             Me.Hide()
  21.             frmResult.picResult.Image = My.Resources.success
  22.         Else
  23.             attempts = attempts + 1
  24.             lblMsg.Text = "You have used " & attempts & " attempts out of 3."
  25.             If attempts = 3 Then
  26.                 frmResult.Show()
  27.                 Me.Hide()
  28.                 frmResult.picResult.Image = My.Resources.failure
  29.             End If
  30.         End If
  31.     End Sub
  32.  
  33.     Private Sub txtPassword_TextChanged(sender As Object, e As EventArgs) Handles txtPassword.TextChanged
  34.         If txtPassword.Text = "" Then
  35.             btnSubmit.Enabled = False
  36.         Else
  37.             btnSubmit.Enabled = True
  38.         End If
  39.     End Sub
  40. End Class
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement