Cod*_*ray 11
在您的登录表单中,我假设您在Click事件方法内执行了按钮控件的验证.所以你会有类似的东西:
Private Sub btnLogin_Click()
If ValidatePassword(txtPassword.Text) Then
' The password is correct, so show the main form and close the login form
MainForm.Show
Unload Me
Else
' The password is incorrect, so leave this form on screen
MsgBox "Invalid password entered!", vbError
txtPassword.SetFocus
End If
End Sub
Run Code Online (Sandbox Code Playgroud)
这段代码的两个有趣特性是:
Show您在要显示的表单对象上调用的方法.
在这种情况下,它可能是你的主要形式 - 替换MainForm它所谓的任何东西.
该Unload声明关闭并销毁指定的表单.
在这种情况下,Me请参阅登录表单,因为您已完成它.