我想爲登錄功能添加登錄嘗試次數。當用戶輸入錯誤的用戶名和密碼3次時,程序應該關閉並顯示一條消息。這裏是我的登錄按鈕代碼在我Form1.vb
:如何對登錄嘗試進行計數Visual Basic
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "13Mendv" And TextBox2.Text = "Admin123" Or
TextBox1.Text = "Admin" And TextBox2.Text = "Admin123" Or
TextBox1.Text = "13PateS" And TextBox2.Text = "Staff123" Or
TextBox1.Text = "13KhetP" And TextBox2.Text = "Member123" Or
TextBox1.Text = "13PateN" And TextBox2.Text = "Scorer123" Or
TextBox1.Text = "13ChatP" And TextBox2.Text = "Captain123" Or
TextBox1.Text = "13BonnN" And TextBox2.Text = "Captain123" Or
TextBox1.Text = "13EarlJ" And TextBox2.Text = "Captain123" Or
TextBox1.Text = "13RajaA" And TextBox2.Text = "Captain123" Or
TextBox1.Text = "1" And TextBox2.Text = "1" Or
TextBox1.Text = "13SchaJ" And TextBox2.Text = "Captain123" Then
Timer1.Start() 'Timer on Form1.vb show
ProgressBar1.Show() 'Progress bar on Form1.vb show
Label8.Show() 'Label8 on Form1.vb show
Button4.Show() 'Button4 on Form1.vb show
Else
If TextBox1.Text = "" And TextBox2.Text = "" Then
MsgBox("No Username and/or Password Found!", MsgBoxStyle.Critical, "Error") 'If statement for checking if there is any input in either username or password entry field
Else
If TextBox1.Text = "" Then
MsgBox("No Username Found!", MsgBoxStyle.Critical, "Error") 'Message box no username found
Else
If TextBox2.Text = "" Then
MsgBox("No Password Found!", MsgBoxStyle.Critical, "Error") 'Message box no password found
Else
MsgBox("Invalid Username And/Or Password!", MsgBoxStyle.Critical, "Error") 'Message box invlaid username and or password
TextBox2.Clear()
End If
End If
End If
End If
End Sub
我能做些什麼,以添加計數到該代碼正常通知他們3次失敗的登錄嘗試的用戶?
'私人NCOUNT爲整數= 0'然後每次失敗'時間NCOUNT = 1'然後退出應用程序時,它會以3 – Plutonix
我肯定有人在那裏讚賞你的廣播你的用戶名和密碼... :) – cHao
感謝您的幫助,非常感謝 –