扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
vb登陆程序源代码\x0d\x0a\x0d\x0a你可以这样做建一个模块在里面输入下列\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=您的数据库名;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 "您已经三次尝试进入本系统,均不成功,系统将自动关闭", 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
成都创新互联公司是一家业务范围包括IDC托管业务,网络空间、主机租用、主机托管,四川、重庆、广东电信服务器租用,南充服务器托管,成都网通服务器托管,成都服务器租用,业务范围遍及中国大陆、港澳台以及欧美等多个国家及地区的互联网数据服务公司。
创建完相应的用户名,密码控件之后,输入以下代码:
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=" 网址"
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 ' 获取或设置一个值,该值指示是否与
Internet资源建立持久连接。
Dim reader As StreamReader = _
New StreamReader(httpResp.GetResponseStream,
System.Text.Encoding.GetEncoding(-0))
Dim respHTML As String = reader.ReadToEnd() 'respHTML就是网页源代码
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流