用数据库吧,你需要建立一个数据库来保存这些用户的登录信息。
数据库的设计包括两个字段,分别保存用户名和密码。数据库名叫“yusion”
表名叫“user”
写代码之前你需要引用ado 控件
具体的办法是添加部件的对话框中选中
Microsoft ActiveX Data ...Object Controls 2.6 这句不是很记得怎么写了。
Private Sub command1_click()
dim conn as new adodb.connection
dim rs as new adodb.recordset
dim str as string
Static logintimes As Integer
dim sql as string
str = App.Path
If Right(str, 1) <> "\" Then
str = str + "\"
End If
str = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=" & str & "\yusion.mdb"
conn.open str ‘这里是打开数据库
rs.cursorlocation=aduseclient
sql="select * from user where 用户名='" & text1.text & "'"
rs.open sql,conn,adopenkeyset.adlockpessimistic ‘这里打开记录_集
if rs.recordset.eof and rs.recordset.bof then
msgbox "没有此用户"
else
if trim(text2.text)=rs.fields("密码").velue then
me.hide
form2.show
else
msgbox "密码错误,请重试!"
text2.setfouse
logintimes=logintimes+1
end if
if logintimes >=3 then
msgbox "你已连续三次输入错误密码,系统将强制退出!"
exit sub
end if
end if
end sub
本答案是我上班时用text打的,可能有个别单词不正确,请检查!
用户名和密码可以在数据库里随意添加。
至于你的三种权限问题可以用多几个if 结构就可以了。