编写程序要求如下:
新建一个工程,添加两个窗体,在第一个窗体(Form1)上分别画标签框(Label1),
文本框(Text1),三个命令按钮:登录(Command1),重输(Command2),退出(Command3)。
程序运行后,在文本框(Text1)中输入密码,如果密码为:password,则显示第二个窗
体(Form2),否则,用MsgBox()函数提示密码错误,不能进入Form2。但如果连续三次输
入的密码都不对,则程序自动结速运行退出。
----------
各位可以给出详细的程序代码吗?
我是一个VB菜鸟兼自学者,还望各位多指教!
谢谢!

解决方案 »

  1.   

    dim a,v 
    private sub command1_click
    a=0
    re:
    if a>=3 then
     end
    end if
    if text1.text="password" then
     form1.hide
     form2.show
    else
     v=msgbox("your password is wrong!",vbyescancel,"msgbox")
      if v=vbyes then
       a=a+1
       goto re
      else
       end
      end if
     end if
    end sub
      

  2.   

    Private Sub Command1_Click()
        Static intNum As Integer
        If Text1.Text <> "password" Then
            If intNum = 2 Then
                MsgBox "三次输入错误密码!", vbInformation, "提示"
                End
            Else
                intNum = intNum + 1
                MsgBox "输入密码不正确!", vbInformation, "提示"
            End If
        Else
            Form2.Show
        End If
    End Sub
      

  3.   

    Private Sub Command1_Click()
       Static I As Integer                       '变量I统计输入错误口令的次数
       If KeyCode = 13 Then                      '如果按下的键为回车键
          If Ucase(Text1.Text) = "password" Then '如果口令为password
             Form2.Show
          ElseIf I = 0 Or I = 1 Then             '如果口令错且错误次数少于2
             I = I + 1
             MsgBox "输入密码错误", vbInformation, "提示"    
             Text1.SelStart = 0                  '反白显示文本框有密码区域
             Text1.SelLength = Len(Text1.Text)   
          Else                                   '如果口令错且错误次数等于2(即已经错了两次,现在是第三次错)
             End                                 '退出程序
          End If
       End If
    End Sub
      

  4.   

    Private Sub Command1_Click()
        Static intNum As Integer
        If Text1.Text <> "password" Then
            If intNum = 2 Then
                MsgBox "三次输入错误密码!", vbInformation, "提示"
                End
            Else
                intNum = intNum + 1
                MsgBox "输入密码不正确!", vbInformation, "提示"
            End If
        Else
            Form2.Show
        End If
    End Sub
      

  5.   

    楼上的这样抄二楼的CODE不厚道啊~~