1、关于VB设计中一个用户登录界面的代码
Fields(1)
你不会直接包含字段名嘛?Fields![字段名]
'注意[
]
里面的不需要加英文引号
或者去掉版后面的
Value
属性
写成权
Adodc1.Recordset.Fields(1)
=
Text1.text
尝试能不能读取到数据库的信息
2、VB登陆系统代码
'如下 WS As Workspace
Dim DB As Database
Dim TB1 As Recordset
Dim StrSql As String'认证
Set WS = DBEngine.Workspaces(0)
Set DB = WS.OpenDatabase(gstrDbName, False, False, gstrDbPws)'gstrDbName access 路径 gstrDbPws 密码
If Text1 = "" Or Text2 = "" Then
MsgBox "用户名和密码不能为空", , "错误提示"
Text1.SetFocus
Else'用户密码存在 表user 中,看表中有没有用户密码都和用户输入的相同的
StrSql = "SELECT * From User Where del=false and UserName = '" & Text1 & "' And PasWord = '" & Text2 & "'"
Set TB1 = DB.OpenRecordset(StrSql, dbOpenDynaset)
If TB1.EOF Then '没有
Label4.Tag = str(Val(Label4.Tag) + 1)
If Val(Label4.Tag) = 3 Then
MsgBox "连续三次输入错误,系统关闭!", , "关闭警告"
Unload Me
End
End If
Label4.Caption = "用户名或密码错误,请重输(第" & Label4.Tag & " 次错误)"
Label4.Visible = True
Text2 = ""
Text1.SetFocus
Else
'用户成功登陆
gstrUserId = TB1("ID")
gstrUserName = TB1("Name")
gstrUserRoot = TB1("Root")'显示主窗口
Load MDIFrmMain
MDIFrmMain.Caption = "计算机管理系统 - 当前用户( " & gstrUserName & " )"
MDIFrmMain.Show
Unload Me
End If '取消代码 就是退出嘛end unload me
3、vb设计登陆界面的代码
?
4、VB制作一个简单登录页面
那是肯定无法实现你说的置换的,你的值是保存在代码里的,那就是固定的,即使你置换了,下次启动程序又恢复到最初值了。要达到你说的置换,就需要使用文件来实现保存、置换更新等等功能。
5、求用VB打开网页的代码
Private Sub Command1_Click() '确定
WebBrowser1.Navigate "www.baidu.com"
End Sub
Private Sub Command2_Click() ‘关闭
WebBrowser1.Navigate "about:blank"
End Sub
添加2个按钮控件 一个 web控件
需要更高回级应用加我百度答HI
6、VB登录窗口制作代码和流程
'主窗口为form2, form1为登陆窗口,上面有2个text、1个command控件
Private Sub Command1_Click()
Static n
If Text1 = "119" Then
If Text2 = "911" Then
Form2.Show
Unload Me
Else
MsgBox "密码错误!"
Text2 = ""
Text2.SetFocus
End If
Else
MsgBox "用户名错误!"
Text1 = ""
Text1.SetFocus
End If
n = n + 1
If n = 3 Then Unload Me '错误次数3次
End Sub
7、VB程序设计 用户登陆界面代码
1.楼上的方法没有必要,一是调用String类型的属性调用ToString方法没有意义,二是应该不是没去空字符的原因,所以Trim应该不能解决问题
2.字段好像Username是关键字(记不清了,呵呵),改为[UserName]试试
3.不知道你的SQL代码是否有误。
4.在检查用户名是否存在的时候,建议用SqlCommand对象的ExecuteScaler方法以节省开销
8、求VB登陆界面详细代码
1.拖出两个 两个command 分别命名为:txtUser ,txtPwd ,cmdLoginEnter ,cmdLoginCancel
2.在程序根目录下新建 date.mdb 数据库 表名为:user
字段1为:username 字段2为:pwd 数据库密码为:111
(可根据) Set dbLogin = OpenDatabase(App.Path + "\Data.mdb", False, False, "MS Access;pwd=111") 修改自定义。
3.复制以下代码。
------------
Option Explicit
Dim intTryTimes As Integer
Dim dbLogin As Database
Dim rstLogin As Recordset
Private Sub cmdLoginCancel_Click()
End
End Sub
Private Sub cmdLoginEnter_Click()
If Me.txtUser = "" Then
MsgBox "用户名不能为空!", vbCritical, Me.Caption
Me.txtUser.SetFocus
GoTo ExitSub
ElseIf Me.txtPwd = "" Then
MsgBox "请填写密码!", vbCritical, Me.Caption
Me.txtPwd.SetFocus
GoTo ExitSub
End If
Set rstLogin = dbLogin.OpenRecordset("select * from User where Username='" + Trim(Me.txtUser) + "'")
If rstLogin.RecordCount = 0 Then
MsgBox "用户名填写错误!", vbCritical, "错误"
Me.txtUser.SetFocus
Me.txtUser.SelStart = 0
Me.txtUser.SelLength = Len(Me.txtUser)
GoTo ExitSub
End If
If rstLogin.Fields("Pwd") = Trim(Me.txtPwd) Then
'登陆成功
' userName = Trim(Me.txtUser)
Unload Me
Form1.Show
' Call Sound("Login")
Else
MsgBox "密码错误!", vbCritical, "错误"
Me.txtPwd.SetFocus
Me.txtPwd.SelStart = 0
Me.txtPwd.SelLength = Len(Me.txtPwd)
End If
GoTo ExitSub
ExitSub:
intTryTimes = intTryTimes + 1
If intTryTimes = 4 Then
MsgBox "密码错误!", vbInformation, Me.Caption
End
End If
End Sub
Private Sub Form_Load()
Me.Left = Screen.Width / 2 - Me.Width / 2
Me.Top = Screen.Height / 2 - Me.Height / 2
Me.Caption = "登陆"
intTryTimes = 0
Set dbLogin = OpenDatabase(App.Path + "\Data.mdb", False, False, "MS Access;pwd=111")
' Set rstLogin = dbLogin.OpenRecordset("select Username from User")
' If rstLogin.RecordCount <> 0 Then
' Me.txtUser = rstLogin.Fields("Username")
' End If
Show
Me.txtUser.SetFocus
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set rstLogin = Nothing
dbLogin.Close
End Sub
Private Sub txtPwd_GotFocus()
Me.txtPwd.SelStart = 0
Me.txtPwd.SelLength = Len(Me.txtPwd)
End Sub
Private Sub txtPwd_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Call cmdLoginEnter_Click
End If
End Sub
Private Sub txtUser_GotFocus()
Me.txtUser.SelStart = 0
Me.txtUser.SelLength = Len(Me.txtUser)
End Sub
Private Sub txtUser_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Call cmdLoginEnter_Click
End If
End Sub
--------------
给分吧!
9、vb用户怎么登录界面?用户登陆的代码是多少?
vb登陆程序源代码
你可以这样做建一个模块在里面输入下列
Public conn As ADODB.Connection
Sub main()
Set conn = New ADODB.Connection
conn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;" _
+ "User ID=sa;password=sa;Initial Catalog=您的数据库名;Data Source=127.0.0.1"
conn.Open
from1.Show ’登录界面
End Sub
再在登录界面“确定”下写入如下代码:
Private Sub Command1_Click()
If id.Text = "" Then
MsgBox "用户名不能为空!", vbOKOnly + vbInformation, "友情提示"
id.SetFocus
Exit Sub
End If
If password.Text = "" Then
MsgBox "密码不能为空!", vbOKOnly + vbInformation, "友情提示"
password.SetFocus
Exit Sub
End If
Dim strSQl As String
strSQl = "select * from Users where users_name='" & Trim$(id.Text) & "' and password='" & Trim$(password.Text) & "' "
Dim str As New ADODB.Recordset
Set str = New ADODB.Recordset
str.CursorLocation = adUseClient
str.Open strSQl, conn, adOpenStatic, adLockReadOnly
With str
If .State = adStateOpen Then .Close
.Open strSQl
If .EOF Then
Try_times = Try_times + 1
If Try_times >= 3 Then
MsgBox "您已经三次尝试进入本系统,均不成功,系统将自动关闭", vbOKOnly + vbCritical, "警告"
Unload Me
Else
MsgBox "对不起,用户名不存在或密码错误 !", vbOKOnly + vbQuestion, "警告"
id.SetFocus
id.Text = ""
password.Text = ""
End If
Else
Unload Me
Form2.Show ’登录进入的另一个界面
End If
End With
End Sub
10、VB自动登录网页,求代码
添加抄一个webbrowser控件袭,然后在它的complete事件里添加代码:
Dim d As Object, o As Object, pc As String