vb登陸程序源代碼\x0d\x0a\x0d\x0a你可以這樣做建一個模塊在里面輸入下列\(zhòng)x0d\x0aPublic conn As ADODB.Connection\x0d\x0aSub main()\x0d\x0a Set conn = New ADODB.Connection\x0d\x0a conn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;" _\x0d\x0a + "User ID=sa;password=sa;Initial Catalog=您的數(shù)據(jù)庫名;Data Source=127.0.0.1"\x0d\x0a conn.Open\x0d\x0afrom1.Show ’登錄界面\x0d\x0aEnd Sub\x0d\x0a\x0d\x0a再在登錄界面“確定”下寫入如下代碼:\x0d\x0aPrivate Sub Command1_Click()\x0d\x0a If id.Text = "" Then\x0d\x0a MsgBox "用戶名不能為空!", vbOKOnly + vbInformation, "友情提示"\x0d\x0a id.SetFocus\x0d\x0a Exit Sub\x0d\x0a End If\x0d\x0a If password.Text = "" Then\x0d\x0a MsgBox "密碼不能為空!", vbOKOnly + vbInformation, "友情提示"\x0d\x0a password.SetFocus\x0d\x0a Exit Sub\x0d\x0a End If\x0d\x0a\x0d\x0a Dim strSQl As String\x0d\x0a strSQl = "select * from Users where users_name='" Trim$(id.Text) "' and password='" Trim$(password.Text) "' "\x0d\x0a \x0d\x0a Dim str As New ADODB.Recordset\x0d\x0a Set str = New ADODB.Recordset\x0d\x0a str.CursorLocation = adUseClient\x0d\x0a str.Open strSQl, conn, adOpenStatic, adLockReadOnly\x0d\x0a \x0d\x0a With str\x0d\x0a If .State = adStateOpen Then .Close\x0d\x0a .Open strSQl\x0d\x0a If .EOF Then\x0d\x0a Try_times = Try_times + 1\x0d\x0a If Try_times = 3 Then\x0d\x0a MsgBox "您已經(jīng)三次嘗試進入本系統(tǒng),均不成功,系統(tǒng)將自動關(guān)閉", vbOKOnly + vbCritical, "警告"\x0d\x0a Unload Me\x0d\x0a Else\x0d\x0a MsgBox "對不起,用戶名不存在或密碼錯誤 !", vbOKOnly + vbQuestion, "警告"\x0d\x0a id.SetFocus\x0d\x0a id.Text = ""\x0d\x0a password.Text = ""\x0d\x0a End If\x0d\x0a Else\x0d\x0a \x0d\x0a Unload Me\x0d\x0a \x0d\x0a Form2.Show ’登錄進入的另一個界面\x0d\x0a \x0d\x0a End If\x0d\x0a End With\x0d\x0a\x0d\x0aEnd Sub
成都創(chuàng)新互聯(lián)公司是一家業(yè)務(wù)范圍包括IDC托管業(yè)務(wù),網(wǎng)絡(luò)空間、主機租用、主機托管,四川、重慶、廣東電信服務(wù)器租用,南充服務(wù)器托管,成都網(wǎng)通服務(wù)器托管,成都服務(wù)器租用,業(yè)務(wù)范圍遍及中國大陸、港澳臺以及歐美等多個國家及地區(qū)的互聯(lián)網(wǎng)數(shù)據(jù)服務(wù)公司。
創(chuàng)建完相應(yīng)的用戶名,密碼控件之后,輸入以下代碼:
Imports System.Data.OleDb
Public Class Form1
Private Sub cmdok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdok.Click
Dim m_username As String
Dim m_userpwd As String
Dim cmd_result As MsgBoxResult
Dim m_da As New OleDbDataAdapter
Dim m_ds As New DataSet
Dim m_command As New OleDbCommand
Dim strsql As String
m_username = txtusername.Text
m_userpwd = txtuserpwd.Text
strsql = " select * from user_info where username='" m_username "' and userpwd='" m_userpwd "'"
OleDbConnection1.Open()
m_command.CommandType = CommandType.Text
m_command.CommandText = strsql
m_command.Connection = OleDbConnection1
m_da.SelectCommand = m_command
m_da.Fill(m_ds, "user_info")
If m_ds.Tables("user_info").Rows.Count 0 Then
cmd_result = MsgBox("歡迎登錄", MsgBoxStyle.OKOnly, "提示")
Else
MsgBox("登錄失敗,請確認用戶名和密碼")
End If
End Sub
End Class
Dim url As String=" 網(wǎng)址"
Dim httpReq As System.Net.HttpWebRequest
Dim httpResp As System.Net.HttpWebResponse
Dim httpURL As New System.Uri(url)
httpReq = CType(WebRequest.Create(httpURL), HttpWebRequest)
httpReq.Method = "GET"
httpResp = CType(httpReq.GetResponse(), HttpWebResponse)
httpReq.KeepAlive = False ' 獲取或設(shè)置一個值,該值指示是否與
Internet資源建立持久連接。
Dim reader As StreamReader = _
New StreamReader(httpResp.GetResponseStream,
System.Text.Encoding.GetEncoding(-0))
Dim respHTML As String = reader.ReadToEnd() 'respHTML就是網(wǎng)頁源代碼
當(dāng)前名稱:vb.net登錄界面源碼 vb用戶登錄界面代碼
URL標(biāo)題:http://jinyejixie.com/article10/doscddo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)建站、軟件開發(fā)、網(wǎng)站內(nèi)鏈、電子商務(wù)、App設(shè)計、服務(wù)器托管
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)