VB登录界面代码显示不出来?急等.....请高手帮助!!!!

来源:百度知道 编辑:UC知道 时间:2024/06/20 05:31:58
我的登录没显示出来,直接就出来了主界面,是怎么回事?以下是我的代码:
Option Explicit

Private Sub cmdCancel_Click()
Dim intResult As Integer
'请求用户确认是否真的退出系统登录
intResult = MsgBox("你选择了退出系统登录,退出将不能启动企业人事管理系统!" & vbcrlf_ & "是否真的退出?", vbYesNo, "登录验证")
If intResult = vbYes Then End
'根据用户选择结束应用程序

End Sub

Private Sub CmdOK_Click()
Dim UserName As String
Dim userpassword As String
Dim str As String
Dim nTryCount As Integer
Dim rs As New ADODB.Recordset
Set rs = New ADODB.Recordset
UserName = Trim(txtUserName.Text)
userpassword = Trim(txtpassword.Text)

str = "select * from 用户信息表 where 用户名='" & UserName & "' and 用户密码 = '" & userpassword & " '"
rs.Open str, connectString, adOpenKeyset, 2

If rs.EOF Then '登录失败
MsgBox "对不起,无此用户或者密码不正确!请重新输入!!", vbCritical, "错误"
txtUser

你用的是多窗体,而设置启动窗体为主界面,所以会不用登陆就显示了.

点击菜单栏里的“工程”-“属性”再将启动对象设为你要的登录窗体.就可以了。

在工程属性里将你的启动对象设为你的登录窗体.