Public Class login
Inherits System.Windows.Forms.Form
Dim myQuery As String
Dim intCmbCnt As Integer
Dim main As Main
Private Sub Initialize()
Me.cmbName.SelectedText = ""
Me.cmbName.Text = ""
Me.txtPassword.Text = ""
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnexit.Click
Me.Close()
End Sub
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
Dim myclsdb As New clsDB
If Me.cmbName.Text = "" Then
MsgBox("请输入用户名!", MsgBoxStyle.Exclamation)
Me.cmbName.Focus()
Exit Sub
End If
If Me.txtPassword.Text = "" Then
MsgBox("请输入密码!", MsgBoxStyle.Exclamation)
Me.txtPassword.Focus()
Exit Sub
End If
myQuery = "select * from 操作员表 where 用户名 ='" & Me.cmbName.Text.ToString & "'and 密码='" & Me.txtPassword.Text.ToString & "'"
If myclsdb.DB(myQuery) = False Then
'GoTo exit_btnok_click
Else
If myclsdb.DataSet.Tables(0).Rows.Count = 0 Then
MsgBox("请输入正确的用户名和密码!", MsgBoxStyle.Exclamation)
Else
main.setPermission(True)
Me.Close()
End If
End If
End Sub
Private Sub Control_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cmbName.KeyDown, txtPassword.KeyDown, btnOK.KeyDown, btnexit.KeyDown
Dim W_Sendkeys As SendKeys
If e.KeyCode = Keys.Up Or e.KeyCode = Keys.Down Then
e.Handled = True
End If
Select Case e.KeyCode
Case Keys.Return
W_Sendkeys.Send("{TAB}")
Case Keys.Down
W_Sendkeys.Send("{TAB}")
Case Keys.Up
W_Sendkeys.Send("+{TAB}")
End Select
End Sub
Private Sub login_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call Initialize()
Dim arr As New ArrayList
Dim myclsDB As New clsDB
myQuery = "select * from 操作员表"
If myclsDB.DB(myQuery) = False Then
Exit Sub
Else
For intCmbCnt = 0 To myclsDB.DataSet.Tables(0).Rows.Count - 1
arr.Add(myclsDB.DataSet.Tables(0).Rows(intCmbCnt).Item("用户名"))
Next
End If
cmbName.DataSource = arr
cmbName.SelectedIndex = -1
cmbName.Text = ""
Me.cmbName.Focus()
End Sub
End Class
代码出错!!说未找到“Sub Main”。
本人不明白!!请高手指教下!!!