Dim trd As Threading.Thread = New Threading.Thread(AddressOf timeDown) Dim trd2 As Threading.Thread = New Threading.Thread(AddressOf checkKey) Dim key As String = "111" Dim seconds As Integer = 60 Dim ran As Boolean = False Private Function isNumber(ByVal s As String) If (s = "0" Or s = "1" Or s = "2" Or s = "3" Or s = "4" Or s = "5" Or s = "6" Or s = "7" Or s = "8" Or s = "9") Then Return True End If Return False End Function
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged If Not (isNumber(sender.ToString().Chars(sender.ToString().Length - 1))) Then TextBox1.Text = "" End If End Sub Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged If Not (isNumber(sender.ToString().Chars(sender.ToString().Length - 1))) Then TextBox2.Text = "" End If End Sub Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles TextBox3.TextChanged If Not (isNumber(sender.ToString().Chars(sender.ToString().Length - 1))) Then TextBox3.Text = "" End If End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load CheckForIllegalCrossThreadCalls = False TextBox1.Enabled = False TextBox2.Enabled = False TextBox3.Enabled = False End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click If (Not ran) Then ran = True Dim rand As Random = New Random key = "" For i As Integer = 0 To 2 Dim r As Integer = rand.Next(9) key &= r r = Nothing Next 'MsgBox(key)' Uncomment to see the key for testing. TextBox1.Enabled = True TextBox2.Enabled = True TextBox3.Enabled = True trd.IsBackground = True trd.Start() trd2.IsBackground = True trd2.Start() End If End Sub
Private Function checkKey() Do Until seconds = 0 Dim s As String = TextBox1.Text & TextBox2.Text & TextBox3.Text If (s = key) Then MsgBox("You found the key! You Ninja.") If (trd.IsAlive) Then trd.Suspend() If (trd2.IsAlive) Then trd2.Suspend() TextBox1.Enabled = False TextBox2.Enabled = False TextBox3.Enabled = False seconds = 0 End If Loop seconds = 60 End Function Private Function timeDown() Do Until seconds = 0 seconds -= 1 Label2.Text = seconds Threading.Thread.Sleep(1000) Loop TextBox1.Enabled = False TextBox2.Enabled = False TextBox3.Enabled = False End Function
Public Class Form1 Dim trd As Threading.Thread = New Threading.Thread(AddressOf timeDown) Dim trd2 As Threading.Thread = New Threading.Thread(AddressOf checkKey) Dim key As String = "111" Dim seconds As Integer = 60 Dim ran As Boolean = False Private Function isNumber(ByVal s As String) If (s = "0" Or s = "1" Or s = "2" Or s = "3" Or s = "4" Or s = "5" Or s = "6" Or s = "7" Or s = "8" Or s = "9") Then Return True End If Return False End Function Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged If Not (isNumber(sender.ToString().Chars(sender.ToString().Length - 1))) Then TextBox1.Text = "" End If End Sub Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged If Not (isNumber(sender.ToString().Chars(sender.ToString().Length - 1))) Then TextBox2.Text = "" End If End Sub Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles TextBox3.TextChanged If Not (isNumber(sender.ToString().Chars(sender.ToString().Length - 1))) Then TextBox3.Text = "" End If End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load CheckForIllegalCrossThreadCalls = False TextBox1.Enabled = False TextBox2.Enabled = False TextBox3.Enabled = False End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click If (Not ran) Then ran = True Dim rand As Random = New Random key = "" For i As Integer = 0 To 2 Dim r As Integer = rand.Next(9) key &= r r = Nothing Next 'MsgBox(key)' Uncomment to see the key for testing. TextBox1.Enabled = True TextBox2.Enabled = True TextBox3.Enabled = True trd.IsBackground = True trd.Start() trd2.IsBackground = True trd2.Start() End If End Sub Private Function checkKey() Do Until seconds = 0 Dim s As String = TextBox1.Text & TextBox2.Text & TextBox3.Text If (s = key) Then MsgBox("You found the key! You Ninja.") If (trd.IsAlive) Then trd.Suspend() If (trd2.IsAlive) Then trd2.Suspend() TextBox1.Enabled = False TextBox2.Enabled = False TextBox3.Enabled = False seconds = 0 End If Loop seconds = 60 End Function Private Function timeDown() Do Until seconds = 0 seconds -= 1 Label2.Text = seconds Threading.Thread.Sleep(1000) Loop TextBox1.Enabled = False TextBox2.Enabled = False TextBox3.Enabled = False End Function End Class
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.