解决方案资源管理器中右键菜单,添加,WINDOWS窗体,弹出的对话框中,左栏已安装的模板中选择WINDOWS FORMS ,右边中找到 登录窗体。添加 。程序会添加一个登录界面。很方便。你试下。
成都创新互联公司自成立以来,一直致力于为企业提供从网站策划、网站设计、成都做网站、网站制作、成都外贸网站建设、电子商务、网站推广、网站优化到为企业提供个性化软件开发等基于互联网的全面整合营销服务。公司拥有丰富的网站建设和互联网应用系统开发管理经验、成熟的应用系统解决方案、优秀的网站开发工程师团队及专业的网站设计师团队。
Private Sub SendBlogTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SendBlogTimer.Tick
Dim textboxUserId As HtmlElement
Dim textboxPassword As HtmlElement
Dim buttonSubmit As HtmlElement
textboxUserId = SendBlogBrowser.Document.All("username")'获取用户名输入框
textboxPassword = SendBlogBrowser.Document.All("password")'获取密码输入框
buttonSubmit = SendBlogBrowser.Document.All("btnLogin")'获取登陆按钮
textboxUserId.SetAttribute("value","用户名")'给用户名输入框赋值
textboxPassword.SetAttribute("value","密码")'给密码框赋值
buttonSubmit.InvokeMember("click")’执行登陆按钮的单击
End Sub
其中的SendBlogBrowser为WebBrowser控件
Label1.Caption = "融通系统外挂程序"
If Dir(App.Path "/hjw.mdb") "" Then
Set mydata = OpenDatabase(App.Path "\hjw")
Set myrs1 = mydata.OpenRecordset("user", dbOpenTable)
Else
Set mydata = CreateDatabase(App.Path "\hjw", dbLangGeneral, dbVersion40)
mydata.Execute "create table ku (建立日期 text(100),库名 text(100),功能 text(100))"
mydata.Execute "create table system (店号 integer,建立日期 text(100),文件路径 text(100),软件版本 text(100),路径1 text(50),路径2 text(50),路径3 text(50),路径4 text(50))"
kuname = "system"
kugn = "文件信息"
Me.showlist1
mydata.Execute "create table user (user text(50),passwd text(50),name text(50),quanx integer)"
kuname = "user"
kugn = "用户信息"
Me.showlist1
Private Sub cmdOK_Click()
txtUserName.SetFocus
If Trim(txtUserName.Text = "") Then
MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
txtUserName.SetFocus
Else
sql = "select * from user where user = '" txtUserName.Text "'"
'Debug.Print sql
'Set mrc = ExecuteSQL(sql, MsgText)
Set myrs2 = mydata.OpenRecordset(sql)
If myrs2.EOF = True Then
MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
txtUserName.SetFocus
Else
If Trim(myrs2.Fields(1)) = Trim(txtPassword.Text) Then
UserName = myrs2.Fields(2)
myrs2.Close
Me.Hide
' UserName = Trim(txtUserName.Text)
'Debug.Print UserName
MDIform1.Show
Else
MsgBox "输入密码不正确,请重新输入!", vbOKOnly + vbExclamation, "警告"
txtPassword.SetFocus
txtPassword.Text = ""
End If
End If
End If
End Sub
建个模块, Dim varcnn As OleDb.OleDbConnection ReadOnly Property cnn() As OleDb.OleDbConnection
Get
If varcnn Is Nothing OrElse varcnn.State ConnectionState.Open Then Dim cnstr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=""" My.Application.Info.DirectoryPath "\Contact.mdb"";Persist Security Info=True"
varcnn = New OleDbConnection(cnstr)
varcnn.Open()
End If
Return varcnn
End Get
登录窗体,新建一个就行了。代码Public Class LoginForm1
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
Using cmd As New OleDb.OleDbCommand("select password from tbuser where userid =?", cnn)
cmd.Parameters.Add("?", OleDbType.VarChar).Value = Me.UsernameTextBox.Text
Dim obj As Object = cmd.ExecuteScalar
If (Not IsDBNull(obj)) AndAlso (obj IsNot Nothing) AndAlso obj = PasswordTextBox.Text Then
Me.DialogResult = Windows.Forms.DialogResult.OK
Else MessageBox.Show("密码不正确!") Return
End If
End Using Me.Close()
End Sub Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
Me.DialogResult = Windows.Forms.DialogResult.Cancel
Me.Close()
End SubEnd Class 项目属性里点查看应用程序事件,写代码Namespace My ' 以下事件可用于 MyApplication:
'
' Startup: 应用程序启动时在创建启动窗体之前引发。
' Shutdown: 在关闭所有应用程序窗体后引发。如果应用程序异常终止,则不会引发此事件。
' UnhandledException: 在应用程序遇到未处理的异常时引发。
' StartupNextInstance: 在启动单实例应用程序且应用程序已处于活动状态时引发。
' NetworkAvailabilityChanged: 在连接或断开网络连接时引发。
Partial Friend Class MyApplication
Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup
Dim f As New LoginForm1
If Not f.ShowDialog = DialogResult.OK Then
End
End If
End Sub End ClassEnd Namespace
你测试一下吧。