① 如何在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