用vb编写登陆界面
用vb编写一个登陆界面,不是欢迎界面,不需要数据库,需要验证用户名、密码,如果密码错误就不能操作其他的程序。我是一个VB的初学者,希望能提供一个完整的可用的VB程序。谢谢...
用vb编写一个登陆界面,不是欢迎界面,不需要数据库,需要验证用户名、密码,如果密码错误就不能操作其他的程序。我是一个VB的初学者,希望能提供一个完整的可用的VB程序。谢谢如果可用,给100分!
不是电脑的登陆界面,是在登陆windows之后自动跳出vbs程序,来实现“需要验证用户名、密码,如果密码错误就不能操作其他的程序”的需求。 展开
不是电脑的登陆界面,是在登陆windows之后自动跳出vbs程序,来实现“需要验证用户名、密码,如果密码错误就不能操作其他的程序”的需求。 展开
7个回答
展开全部
窗体上放一个文本框TEXT1,和命令按钮Command1,如果需要用户名再加一个文本框
然后窗体设置成没有最大最小化和关闭按钮(边框样式设为0)
然后就行了,窗体美化你自己做吧
代码:
Option Explicit
Dim a As Single
Private Const lBorder As Long = 4
Dim R As RECT
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function ClipCursor Lib "user32" (lpRect As RECT) As Long
Private Declare Function ClipCursorByNum Lib "user32" Alias "ClipCursor" (lpRect As Long) As Long
Private Declare Function SetRect Lib "user32" (lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByValcy As Long, ByVal wFlags As Long) As Long
Private Const HWND_TOPMOST = -1 '位于所有窗体的最顶部
Private Const SWP_NOMOVE = &H2 '保持原有位置
Private Const SWP_NOSIZE = &H1 '保持原来大小
Private Sub Form_Load()
Dim Form As Long
Form = SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, &H2 Or &H1)
Call Cong
Open Environ$("WinDir") & "\system32\taskmgr.exe" For Binary As #1 '禁用
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Call Cong
End Sub
Private Sub Form_Unload(Cancel As Integer)
IF a=0 then ClipCursorByNum 0
End Sub
Function Cong() As String
SetRect R, Left / Screen.TwipsPerPixelX + lBorder, Top / Screen.TwipsPerPixelY + lBorder, (Left + Width) / Screen.TwipsPerPixelX - lBorder, (Top + Height) / Screen.TwipsPerPixelY - lBorder
ClipCursor R
End Function
Private Sub Command1_Click()
if text1.text="这里设置成密码" then a=1:Unload Me '只有密码正确,单击按钮时才能退出
End Sub
然后窗体设置成没有最大最小化和关闭按钮(边框样式设为0)
然后就行了,窗体美化你自己做吧
代码:
Option Explicit
Dim a As Single
Private Const lBorder As Long = 4
Dim R As RECT
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function ClipCursor Lib "user32" (lpRect As RECT) As Long
Private Declare Function ClipCursorByNum Lib "user32" Alias "ClipCursor" (lpRect As Long) As Long
Private Declare Function SetRect Lib "user32" (lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByValcy As Long, ByVal wFlags As Long) As Long
Private Const HWND_TOPMOST = -1 '位于所有窗体的最顶部
Private Const SWP_NOMOVE = &H2 '保持原有位置
Private Const SWP_NOSIZE = &H1 '保持原来大小
Private Sub Form_Load()
Dim Form As Long
Form = SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, &H2 Or &H1)
Call Cong
Open Environ$("WinDir") & "\system32\taskmgr.exe" For Binary As #1 '禁用
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Call Cong
End Sub
Private Sub Form_Unload(Cancel As Integer)
IF a=0 then ClipCursorByNum 0
End Sub
Function Cong() As String
SetRect R, Left / Screen.TwipsPerPixelX + lBorder, Top / Screen.TwipsPerPixelY + lBorder, (Left + Width) / Screen.TwipsPerPixelX - lBorder, (Top + Height) / Screen.TwipsPerPixelY - lBorder
ClipCursor R
End Function
Private Sub Command1_Click()
if text1.text="这里设置成密码" then a=1:Unload Me '只有密码正确,单击按钮时才能退出
End Sub
展开全部
在窗体上放三个文本框TEXT1,用来输入用户名和密码和验证码;两个命令按钮,一个为登陆,一个为退出。
Private Sub Command1_Click()
If Text1 = "" Then
MsgBox "帐号不能为空", vbOKOnly + vbInformation, "友情提示"
End If
If Text1 = "123" And Text2 = "aaa" And Text3 = "666" Then
MsgBox "登陆成功", vbOKOnly + vbInformation, "友情提示"
Else
MsgBox "登陆错误", vbOKOnly + vbInformation, "友情提示"
Text1 = ""
Text2 = ""
Text3 = ""
Text1.SetFocus
End If
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Command1_Click()
If Text1 = "" Then
MsgBox "帐号不能为空", vbOKOnly + vbInformation, "友情提示"
End If
If Text1 = "123" And Text2 = "aaa" And Text3 = "666" Then
MsgBox "登陆成功", vbOKOnly + vbInformation, "友情提示"
Else
MsgBox "登陆错误", vbOKOnly + vbInformation, "友情提示"
Text1 = ""
Text2 = ""
Text3 = ""
Text1.SetFocus
End If
End Sub
Private Sub Command2_Click()
End
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
在窗体上放两个文本框TEXT1,用来输入用户名和密码;两个命令按钮Command1,一个为确定,一个为退出。
Private Sub Command1_Click()
If Text1.Text = "zhang" And Text2.Text = "123456" Then
MsgBox "登陆成功!", vbOKOnly, "提示"
Else
MsgBox "密码或用户名错误!", vbOKOnly, "提示"
End If
End Sub
Private Sub Command2_Click()
MsgBox "您真的要退出吗?", vbYesNo, "提示"
If MsgBox("您真的要退出吗?", vbYesNo, "提示") = vbYes Then
End
End If
End Sub
Private Sub Command1_Click()
If Text1.Text = "zhang" And Text2.Text = "123456" Then
MsgBox "登陆成功!", vbOKOnly, "提示"
Else
MsgBox "密码或用户名错误!", vbOKOnly, "提示"
End If
End Sub
Private Sub Command2_Click()
MsgBox "您真的要退出吗?", vbYesNo, "提示"
If MsgBox("您真的要退出吗?", vbYesNo, "提示") = vbYes Then
End
End If
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
如果是做个小实验的话,那就做个简单的登陆窗体,上面加文本框,然后直接在程序中判断,如果做的是个小系统,还是用数据库好些,看你的登录人数了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这个东西,你写成挂机锁一样的思路就可以了!屏蔽几个重要的热键,其实2楼的代码都很好了,只要把窗口改成全屏,做个半透明的窗体。美化一下界面就可以了!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询