标题:一个登陆窗体的问题!!
取消只看楼主
wingqu
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2006-8-2
 问题点数:0 回复次数:1 
一个登陆窗体的问题!!

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”。
本人不明白!!请高手指教下!!!

搜索更多相关主题的帖子: 窗体 Sub Dim Private 
2006-08-02 19:40
wingqu
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2006-8-2
得分:0 

谢谢!
Main那个是我定义的一个窗体啊!!
我想登陆成功后就显示那个窗体的!

2006-08-03 09:47



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-81718-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.048823 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved