日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

vb登录界面编写

發布時間:2023/12/10 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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

總結

以上是生活随笔為你收集整理的vb登录界面编写的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。