我有一個用戶窗體2文本框,2個標籤和登錄按鈕。Excel VBA文本框重置爲0當我按下按鈕
在我的Excel表格中,我有一個ID,名稱,別針和平衡的數據庫。
問題是每當我點擊登錄按鈕我的ID文本框將其值重置爲0,但我的PIN文本框工作正常!
我會貼上我的完整代碼:
Dim ID As Integer
Dim PIN As Integer
Dim PINField As String
Dim Balance As Double
Dim Attempts As Integer
Dim BalanceField As String
Private Sub btnLogin_Click()
txtID.Text = ID
Call SetId
Call Authenticate
End Sub
Sub Authenticate()
If txtPin.Text = PIN Then
Call Welcome
ElseIf Attempts > 3 Then
Call Bye
Else
lblWelcome.Caption = "Wrong Pin"
lblWelcome.ForeColor = RGB(255, 0, 0)
Attempts = Attempts + 1
End If
End Sub
Sub SetId()
PINField = "C" & Str(ID)
PINField = Replace(PINField, " ", "")
MsgBox (PINField)
BalanceField = "D" & Str(ID)
BalanceField = Replace(BalanceField, " ", "")
MsgBox (BalanceField)
End Sub
Sub Welcome()
MsgBox ("Login Successful. Welcome")
End Sub
Sub Bye()
MsgBox ("Max Pin Attempts reached. Contact Your Bank")
Unload frmLogin
End Sub
你從哪裏得到'ID'?當你說文本框重置,你指的是'txtID'? – bonCodigo