200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > vb登录界面编写

vb登录界面编写

时间:2022-03-08 19:19:48

相关推荐

vb登录界面编写

VB 登录界面编写

登录界面展示(此篇只有登录代码)

登录代码

Private Sub Command1_Click() 'command1是登录的按钮

Dim no,np, np,np, i%, j%, b%, p%

b = 0

p = 0

If Text1.text = “” Then 'text1是用户名的label

MsgBox (“请先输入用户名!”)

Text1.SetFocus

End If

If Text2.text = “” And Text1.text <> “” Then 'text2是密码的label

MsgBox (“请输入密码!”)

Text2.SetFocus

End If

If Text1.text <> “” And Text2.text <> “” Then

b = 1

End If

If b = 1 Then

Open “” & App.Path & “\save.txt” For Input As #1 '打开存储用户名及密码的文件夹并使用相对路径 app.path

j = 0

Do While Not EOF(1)

Input #1, no

If Text1.text = no Then

j = 1

Exit Do

End If

Loop

If j = 0 Then

MsgBox (“您还不是已注册用户,请先注册!”)

Text1.text = “”

Text2.text = “”

Else

p = 1

End If

Close #1

Else

End If

If p = 1 Then

Open “” & App.Path & “\pipei.txt” For Input As #1

i = 0

Do While Not EOF(1)

Input #1, np

If Text1.text + Text2.text = np Then

i = 1

Form2.Show

Unload Me

Exit Do

End If

Loop

If i = 0 Then

MsgBox (“密码错误!”)

Text2.text = “”

End If

Close #1

Else

End If

End Sub

Private Sub Command2_Click()

Label5.Caption = “”

Form3.Show

Unload Me

End Sub

Private Sub Form_Load() //设置各个label、command、text的大小

Label1.Left = (Me.ScaleWidth - Label1.Width) \ 2

Label2.Left = (Me.ScaleWidth - 0.8 * Label3.Width) \ 2

Label3.Left = (Me.ScaleWidth - Label3.Width) \ 2

Command1.Left = (Me.ScaleWidth - 2.5 * Command1.Width) \ 2

Command2.Left = (Me.ScaleWidth + 0.5 * Command2.Width) \ 2

Text1.Left = (Me.ScaleWidth - Text2.Width + 500) \ 2

Label5.Left = Text1.Left + 400

Label4.Left = Label2.Left

Text2.Left = Text1.Left

Label7.Left = (Me.ScaleWidth - Label1.Width) \ 2

End Sub

Sub Text1_KeyPress(KeyAscii As Integer)

Dim f%

f = 0

If KeyAscii = 13 Then

If IsNumeric(Text1) Then

Text1.text = “”

MsgBox (“用户名中不得包含数字!”)

Text1.SetFocus

f = 1

End If

If f = 0 And Text1.text = “” Then

Text1.text = “”

MsgBox (“请输入用户名!”)

End If

If f = 0 And Text1.text <> “” Then

Text2.SetFocus

End If

End If

End Sub

Private Sub Text1_LostFocus()

If IsNumeric(Text1) Then

Text1.text = “”

MsgBox (“用户名中不得包含数字!”)

Text2.SetFocus

End If

End Sub

Private Sub Text2_GotFocus()

If Text1.text = “” Then

Text1.text = “”

MsgBox (“请输入用户名!”)

End If

Label5.Caption = “密码的长度不得超过8位!”

Text2.Locked = False

Text2.PasswordChar = “*”

End Sub

Private Sub Text2_LostFocus()

If Text1.text = “” Then

MsgBox (“密码错误!”)

Text2.text = “”

End If

End Sub

Private Sub Timer1_Timer() //界面展示上有个闹钟按键 可以显示当前时间

Timer1.Interval = 1000

**label7.Caption =now()**

End Sub

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。