Private Sub Command1_Click()
Dim a As String
Dim Int1 As Integer
If Len(Text1.Text) <= 0 Then
MsgBox "请输入用户名", vbOKOnly, "错误"
Exit Sub
End If
If Len(Text2.Text) = 0 Then
MsgBox "请输入密码", vbOKOnly, "错误"
Exit Sub
End If
UserName = Trim(Text1.Text)
PassWord = Trim(Text2.Text)
Int1 = Check_Password(UserName, PassWord)
Select Case Int1
Case 0
a = MsgBox("登陆成功", vbOKOnly, "成功")
Load Mainfrm
Mainfrm.Show
Unload Me
Case 1
a = MsgBox("密码错误", vbOKOnly, "失败")
Case 2
a = MsgBox("用户名不存在", vbOKOnly, "失败")
End Select
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Command3_Click(Index As Integer)
Select Case Index
Case 0
Load Cpwdfrm
Cpwdfrm.Show
Case 1
Load MGfrm
MGfrm.Show
End Select
End Sub
Private Sub Form_Load()
Me.Caption = "浴池管理系统" &"-------" &"子辰工作室出品"
PassWordPath = "F:\vb\浴池计时系统\pwd.pwd"
End Sub
=============
Const PassWordPath = "F:\vb\浴池计时系统\pwd.pwd"
Private Sub Command1_Click(Index As Integer)
Dim str1 As Integer
Dim str2 As String
Dim str As String
Dim i As Integer
Dim filenum As String
Dim masg As String
'On Error GoTo error1
filenum = FreeFile
UserName = Trim(Text1.Text)
PassWord = Trim(Text2.Text)
Select Case Index
Case 0
str1 = Check_Password(Trim(Text1.Text), Trim(Text2.Text))
Select Case str1
Case 0
NewPD = Trim(Text3.Text)
If Len(Text2.Text) = 0 Then
str2 = MsgBox("请输入密码", vbOKOnly, "错误")
Exit Sub
ElseIf Len(Text3.Text) >0 Then
If Trim(Text3.Text) <>Trim(Text4.Text) Then
str2 = MsgBox("两次密码输入不一致", vbOKOnly, "错误")
Exit Sub
ElseIf Trim(Text3.Text) = Trim(Text4.Text) Then
masg = Change_Password(Trim(Text1.Text), Trim(Text2.Text))
End If
End If
Case 1
str2 = MsgBox("旧密码输入错误", vbOKOnly, "错误")
Case 2
str2 = MsgBox("用户名不存在", vbOKOnly, "错误")
End Select
Case 1
Unload Me
End Select
error1:
Exit Sub
End Sub
Private Sub Form_Load()
Me.Caption = "密码修改"
End Sub
==================
Option Explicit
Public PassWordPath As String
Public UserName As String
Public PassWord As String
Public UserState As Integer
Public UserClass As Integer
Public NewPD As String
Type PWD'自定义数据类型
UN As String * 15
PWD As String * 15
PC As String * 1
End Type
Public Function Change_Password(UserName As String, PassWord As String)
Dim filenum As String
filenum = FreeFile
Dim pswd As PWD
Dim i As Integer
Dim masg As String
PassWordPath = "F:\vb\浴池计时系统\pwd.pwd"
Open PassWordPath For Random As #filenum Len = Len(pswd)
Do Until EOF(filenum)
i = i + 1
Get #filenum, i, pswd
If Trim(pswd.UN) = UserName Then
pswd.PWD = NewPD
Put #filenum, i, pswd
masg = MsgBox("密码修改成功", vbOKOnly, "成功")
Exit Do
End If
Loop
Close #filenum
End Function
Public Function Check_Password(UserName As String, PassWord As String) As Integer
Dim i As Integer
Dim filenum As Integer
Dim pswd As PWD
'On Error GoTo error1
filenum = FreeFile
Open PassWordPath For Random As #filenum Len = Len(pswd)
i = 0
Do Until EOF(filenum)
i = i + 1
Get #filenum, i, pswd
If Trim(pswd.UN) = Trim(UserName) Then
If Trim(pswd.PWD) = PassWord Then
UserState = 0 '登陆成功
UserClass = Val(Trim(pswd.PC))
Exit Do
Else
UserState = 1 '密码错误
End If
Exit Do'正确验证后跳出
Else
UserState = 2'用户名不存在
Exit Do
End If
Loop
Close #filenum
Check_Password = UserState
error1:
Exit Function
End Function
vb登陆程序源代码\x0d\x0a\x0d\x0a你可以这样做建一个模块在里面输入下列\x0d\x0aPublic conn As ADODB.Connection\x0d\x0aSub main()\x0d\x0aSet conn = New ADODB.Connection\x0d\x0a conn.ConnectionString = "Provider=SQLOLEDB.1Persist Security Info=False" _\x0d\x0a + "User ID=sapassword=saInitial Catalog=您的数据库名Data Source=127.0.0.1"\x0d\x0aconn.Open\x0d\x0afrom1.Show ’登录界面\x0d\x0aEnd Sub\x0d\x0a\x0d\x0a再在登录界面“确定”下写入如下代码:\x0d\x0aPrivate Sub Command1_Click()\x0d\x0a If id.Text = "" Then\x0d\x0aMsgBox "用户名不能为空!", vbOKOnly + vbInformation, "友情提示"\x0d\x0aid.SetFocus\x0d\x0aExit Sub\x0d\x0aEnd If\x0d\x0aIf password.Text = "" Then\x0d\x0aMsgBox "密码不能为空!", vbOKOnly + vbInformation, "友情提示"\x0d\x0apassword.SetFocus\x0d\x0aExit Sub\x0d\x0aEnd If\x0d\x0a\x0d\x0aDim strSQl As String\x0d\x0astrSQl = "select * from Users where users_name='" &Trim$(id.Text) &"' and password='" &Trim$(password.Text) &"' "\x0d\x0a\x0d\x0aDim str As New ADODB.Recordset\x0d\x0aSet str = New ADODB.Recordset\x0d\x0astr.CursorLocation = adUseClient\x0d\x0astr.Open strSQl, conn, adOpenStatic, adLockReadOnly\x0d\x0a\x0d\x0aWith str\x0d\x0aIf .State = adStateOpen Then .Close\x0d\x0a.Open strSQl\x0d\x0aIf .EOF Then\x0d\x0aTry_times = Try_times + 1\x0d\x0aIf Try_times >= 3 Then\x0d\x0aMsgBox "您已经三次尝试进入本系统,均不成功,系统将自动关闭", vbOKOnly + vbCritical, "警告"\x0d\x0aUnload Me\x0d\x0aElse\x0d\x0aMsgBox "对不起,用户名不存在或密码错误 !", vbOKOnly + vbQuestion, "警告"\x0d\x0aid.SetFocus\x0d\x0aid.Text = ""\x0d\x0apassword.Text = ""\x0d\x0aEnd If\x0d\x0aElse\x0d\x0a\x0d\x0aUnload Me\x0d\x0a\x0d\x0a Form2.Show’登录进入的另一个界面\x0d\x0a\x0d\x0aEnd If\x0d\x0aEnd With\x0d\x0a\x0d\x0aEnd Subcn.Open "Provider=Microsoft.Jet.OLEDB.4.0Data Source=" &"Z:\专用管理\data\data.mdbJet OLEDB:Database Password=cjw123456Persist Security Info=False"打开网上邻居以后,映射一下网络驱动器
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)