Private Sub Command1_Click()
Static a As Integer
Static b As Integer(这个变量没有值,显示我EMPTY,我用监视看的)
Static c As Integer(这个变量没有值,显示我EMPTY,我用监视看的)请问怎么解决这个问题?
Select Case Combo1.ListIndex
    Case 0
        Adodc1.CommandType = adCmdUnknown
        Adodc1.RecordSource = "select * from 管理员 where id='" & Trim(Text1.Text) & "'" & " and password='" & Trim(Text2.Text) & "'"
        Adodc1.Refresh
            If Adodc1.Recordset.RecordCount <> 0 Then
                MDIForm1.Show
                Form1.Hide
            Else
                MsgBox "帐号和密码有错误,请重新输入!", , "系统提示"
                Text1.Text = ""
                Text2.Text = ""
                Text1.SetFocus
                a = a + 1
                    If a = 3 Then
                        MsgBox "你已输入三次错误密码和帐号,即将退出系统!", , "系统提示"
                        Form1.Hide
                        Form3.Show
'                        c = a + b
'                            If c = 3 Then
'                                MsgBox "你已输入三次错误密码和帐号,即将退出系统!", , "系统提示"
'                                Form1.Hide
'                                Form3.Show
'                            End If
                    End If
            End If
    Case 1
        Adodc1.CommandType = adCmdUnknown
        Adodc1.RecordSource = "select * from 一般 where id='" & Trim(Text1.Text) & "'" & " and password='" & Trim(Text2.Text) & "'"
        Adodc1.Refresh
            If Adodc1.Recordset.RecordCount <> 0 Then
                MDIForm1.Show
                Form1.Hide
                MDIForm1.menu_25.Visible = False
            Else
                MsgBox "帐号和密码有错误,请重新输入!", , "系统提示"
                Text1.Text = ""
                Text2.Text = ""
                Text1.SetFocus
                b = b + 1
                    If b = 3 Then
                        MsgBox "你已输入三次错误密码和帐号,即将退出系统!", , "系统提示"
                        Form1.Hide
                        Form3.Show
                            'c = a + b
'                                If c = 3 Then
'                                    MsgBox "你已输入三次错误密码和帐号,即将退出系统!", , "系统提示"
'                                    Form1.Hide
'                                    Form3.Show
'                                End If
                    End If
            End If
End Select
End Sub

解决方案 »

  1.   

    就是两个变量不计数。B和C。都显示为空值,但是VB没有给值的变量都是0啊。我不知道
       怎么会事,你知道吗?
      

  2.   

    C是用来判断管理和一般用户输入错误的+起来的次数。
        A是管理用户输入错误的次数
        B是一般用户输入错误的次数
        主要是屏蔽掉三次错误的全部可能性,就这样啊。
        55555555555.HELP ME!~
      

  3.   

    呵呵~~你做的还真复杂啊,反正大家都是3次,还分管理员和用户干什么?
    而且你的大部分程序都是重复的,需要简练一下,变量使用时最好初始化一下
    Case 0
            Adodc1.CommandType = adCmdUnknown
            Adodc1.RecordSource = "select * from 管理员 where id='" & Trim(Text1.Text) & "'" & " and password='" & Trim(Text2.Text) & "'"Case 1
            Adodc1.CommandType = adCmdUnknown
            Adodc1.RecordSource = "select * from 一般 where id='" & Trim(Text1.Text) & "'" & " and password='" & Trim(Text2.Text) & "'"End Select            Adodc1.Refresh
                If Adodc1.Recordset.RecordCount <> 0 Then
                    MDIForm1.Show
                    Form1.Hide
                    MDIForm1.menu_25.Visible = False
                Else
                    MsgBox "帐号和密码有错误,请重新输入!", , "系统提示"
                    Text1.Text = ""
                    Text2.Text = ""
                    Text1.SetFocus
                    c = c + 1
                        If c = 3 Then
                            MsgBox "你已输入三次错误密码和帐号,即将退出系统!", , "系统提示"
                            Form1.Hide
                            Form3.Show
                                
                        End If
                End If
      

  4.   

    大鸟这样写确实是很精练,但是有一个问题啊。
      管理用户登陆和一般用户登陆看见的MDI窗体的内容是不一样的,
      如果不在CASE里做一下判断,而直接放到CASE外,那么你这么写就不能判断管理用户是看哪些,一般用户又是看哪些内容了,你这样写只要查询到就直接打开MDI了,那个分权限就没用到。呵呵。对吗?~
      还有大鸟兄兄有没有QQ或者联系的方式啊,以后有啥不懂的可以直接CALL商量一下,恳请大鸟兄兄成全。