以下是我寫的程式碼,我是希望在輸入錯誤的密碼時能選擇重填或是取消進入程式。現在的是問題我選擇取消進入主程式時,本應該結束的這所有程式的,但卻進入了主程式當中,只是所有的功能皆失效了,不知道是不是我的程試碼有問題?請大家幫幫忙,謝謝大家!!
Private Sub Form_Load()
frmPword.Show 1
End Sub
Dim password As String
Private Sub txtPword_keypress(KeyAscii As Integer)
password = "kay"
If KeyAscii = 13 Then
If password = txtPword.Text Then
MsgBox "您的通行證號碼無誤!!歡迎進入本程式", 48, "測試"
Unload frmPword
Else
Button = MsgBox("您輸入的密碼錯誤!再試一次?", 4 + 48, "測試")
If Button = 7 Then
End
Else
txtPword.Text = ""
Beep
End If
End If
End If
End Sub
Private Sub Form_Load()
frmPword.Show 1
End Sub
Dim password As String
Private Sub txtPword_keypress(KeyAscii As Integer)
password = "kay"
If KeyAscii = 13 Then
If password = txtPword.Text Then
MsgBox "您的通行證號碼無誤!!歡迎進入本程式", 48, "測試"
Unload frmPword
Else
Button = MsgBox("您輸入的密碼錯誤!再試一次?", 4 + 48, "測試")
If Button = 7 Then
End
Else
txtPword.Text = ""
Beep
End If
End If
End If
End Sub
文章標籤
全站熱搜

Private Sub Form_Load() frmPword.Show 1 End Sub --------------------以下是frmpword.frm檔 Dim password As String Private Sub txtPword_keypress(KeyAscii As Integer) password = "kay" If KeyAscii = 13 Then If password = txtPword.Text Then MsgBox "您的通行證號碼無誤!!歡迎進入本程式", 48, "測試" Unload frmPword Else Button = MsgBox("您輸入的密碼錯誤!再試一次?", 4 + 48, "測試") If Button = 7 Then End Else txtPword.Text = "" Beep End If End If End If End Sub
你沒有call到cancle button 試把這段加上去看看 Private Sub cmdCancel_Click() '設定全域變數為 false 來代表 '失敗的登入 LoginSucceeded = False Me.Hide End Sub
我在end前加入unload 主程式就可以了。感謝大家的幫忙!!