導航:首頁 > 萬維百科 > vb登陸網頁設計代碼是什麼

vb登陸網頁設計代碼是什麼

發布時間:2021-01-05 04:53:02

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
    On Error Resume Next
    Set d = web.Document
    If d Is Nothing Then Exit Sub
    
    Set o = d.getElementById("username")
    o.Value = "admin"
    Set o = d.getElementById("pwd_")
    o.Value = "123456"
    web.Navigate "javascript:checkLogin();void 0"

與vb登陸網頁設計代碼是什麼相關的知識