Private Sub Command1_Click()
Dim i As Long
Dim t As Integer
Static count As Integer
start:
    i = InputBox("请输入密码", "", "******", _
    2400, 2400)
    If i = "123456" Then
    MsgBox "登陆成功", 0, "确认"
    Unload Me
    Form2.Show
    Else
        count = count + 1
        t = MsgBox("密码错误", 49, "警告")
    End If
    
    
    
   
    If t = 2 Then  '如果点取消masbox的返回值为2
        End
    ElseIf t = 1 And count <=3 Then  '如密码输入次数小3就返回start
        GoTo start
    Else
        MsgBox "密码输入次数过多", 48, "警告"
        End
    End If
   
End Sub
_____________________________________________________________________________
Private Sub Command2_Click()
Unload Me
End Sub
   
    
    
    

解决方案 »

  1.   

    Private Sub Command1_Click()
    Dim stmp As StringDim t As Integer
    Static count As Integer
        Do
            stmp = InputBox("请输入密码", "", "******", _
                2400, 2400)
            If Not IsNumeric(stmp) Then
                
                If stmp = "123456" Then
                    MsgBox "登陆成功", 0, "确认"
                    Unload Me
                    Form2.Show
                    Exit Do
                Else
                    count = count + 1
                    t = MsgBox("密码错误", 49, "警告")
                    If t = 2 Then  '如果点取消masbox的返回值为2
                        End
                    ElseIf t = 1 And count <= 2 Then '如密码输入次数小3就返回start  注意这里
                        
                    Else
                        MsgBox "密码输入次数过多", 48, "警告"
                        End
                    End If
                    
                End If
            End If
            
        Loop
       
       
    End Sub
      

  2.   

    上边写差了 Private Sub Command1_Click()
    Dim stmp As StringDim t As Integer
    Static count As Integer
        Do
            stmp = InputBox("请输入密码", "", "******", _
                2400, 2400)
     
                If stmp = "123456" Then
                    MsgBox "登陆成功", 0, "确认"
                    Unload Me
                    Form2.Show
                    Exit Do
                Else
                    count = count + 1
                    t = MsgBox("密码错误", 49, "警告")
                    If t = 2 Then  '如果点取消masbox的返回值为2
                        End
                    ElseIf t = 1 And count <= 2 Then '如密码输入次数小3就返回start  注意这里
                        
                    Else
                        MsgBox "密码输入次数过多", 48, "警告"
                        End
                    End If
                    
                End If        
        Loop
    End Sub
      

  3.   

    skywolfY(莫愁) 兄谢谢你!
    分数怎么给你啊》????
    我qq 349697414