初学VB编程1星期。 我想把登陆次数弄上去。怎么弄啊? 还有就是登陆次数到了一定的数量就不能登陆了。怎么弄啊??Private Sub Command1_Click()
Dim cs As String
cs = 0 to logintimes do
Const a = "chuans"
Const b = "5088047"
If Text1.Text = a And Text2.Text = b Then
MsgBox "登陆成功!!!^-^", 64
Else
cs = 1
MsgBox "密码错误!!!" & "登陆次数"& cs, 16
End If
End Sub

解决方案 »

  1.   

    Option Explicit
    Dim counter As IntegerPrivate Sub Command1_Click()
    If txtPassword <> "123456" Then
        MsgBox "密码错误!!!" & "登陆次数" & counter + 1, 16
        counter = counter + 1
    End If
    If counter = 3 Then
        Unload Me
    End If
    End SubPrivate Sub Form_Load()
    counter = 0
    End Sub
      

  2.   

    1楼的代码写得不错,这样更精炼些:
    Option Explicit 
    Private Sub Command1_Click() 
    Static counter As Integer 
    If txtPassword.Text <> "123456" Then 
        MsgBox "密码错误!!!" & "登陆次数" & counter + 1, 16 
        counter = counter + 1 
    End If 
    If counter = 3 Then 
        Unload Me 
    End If 
    End Sub