텍스트 상자 2 개, 레이블 2 개 및 로그인 단추가있는 userform이 있습니다.단추를 누를 때 Excel VBA 텍스트 상자가 0으로 재설정됩니다.
내 엑셀 시트에는 ID, 이름, 핀 및 균형이있는 데이터베이스가 있습니다.
문제는 내가 로그인 버튼을 클릭 할 때마다 ID 텍스트 상자의 값이 0으로 재설정되지만 핀 텍스트 상자가 제대로 작동합니다. 당신이 값이없는 변수를 사용하고 있기 때문에
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'는 무엇입니까? textbox reset이'txtID'를 참조한다고 말할 때? – bonCodigo