① 如何在vb中設置密碼,程序該如何編寫
1、選中要設置的控制項
2、按f4調出它的屬性框
3、在其屬性裡面有個「passwordchar"
4、將其後面空中輸入"*"就可以了。
② 怎樣在VB中設置密碼
首先 文件→新建→項目 選擇windows應用程序 並在窗體上添加2個label控制項、2個textbox控制項、2 個buton控制項 界面設計好後在button的click事件中寫入代碼如下: (在程序頂部引用Imports System.Data.OleDb)
Private Sub BOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BOk.Click
'定義
Dim olecn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Data.mdb")
Dim olecm As New OleDbCommand("select * from Login", olecn)
Dim olead As New OleDbDataAdapter
Dim olerd As OleDbDataReader
Dim pd As Boolean = False '定義boolean為後面錯誤處理使用
Dim i As Integer
olecm = New OleDbCommand("select * from Login", olecn)
'與資料庫建立連接
olecn.Open()
olerd = olecm.ExecuteReader
'循環判斷與資料庫中數據是否相同
Do While olerd.Read()
For i = 0 To olerd.FieldCount - 1
If Trim(TUser.Text) = (olerd.Item("帳號")) And Trim(TPassword.Text) = (olerd.Item("密碼")) Then
MsgBox("成功登陸")
pd = True
Exit Sub
End If
Next
Loop
TUser.Text = ""
TPassword.Text = ""
TUser.Focus()
olerd.Close()
olecn.Close()
End Sub
整個過程就做完了簡單吧。
希望對您有所幫助
③ VB怎麼設置賬號密碼
Private Sub Command1_Click()
If Text1.Text = "username" And Text2.Text = "password" Then '帳號為username,密碼為password
MsgBox "輸入正確", vbInformation, "提示"
Unload Me
Form2.Show
Else
MsgBox "帳號或密碼錯誤", vbCritical, "提示"
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
End If
End Sub
Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
Command1.Caption = "登陸"
End Sub