VB 进入FORM2后怎么自动关闭FORM1?

来源:百度知道 编辑:UC知道 时间:2024/06/02 14:06:56
我想要程序FORM1进入FORM2的时候,自动关闭自身。
而且FORM2后退到FORM1的时候自动关闭自身。
那下列程序应该加在哪里呢 ?我要隐藏程序~~~~`

Private Sub Command1_Click()

If Text1 = "123456" Then
MsgBox "密码正确,允许登录"
Load Form2
Form2.Show
Else
Text1 = ""
PassNum = PassNum + 1
MsgBox "警告:密码错误"
Text1.SetFocus
End If
End Sub

Private Sub Form_Load()
PassNum = 0
Text1 = ""
Text1.PasswordChar = "*"
Text1.MaxLength = 6
Command1.Caption = "登录"
Command1.Default = True
Me.Show

Text1.SetFocus

Timer1.Interval = 1000
End Sub

Private Sub Timer1_Timer()
Label1.Caption = Year(Date) & "年" & Month(Date) & "月" & Day(Date) & "日 " & Time & " 星期" & Weekday(Now) - 1

End Sub

unload form1 '卸载form1,从内存中卸载掉
forma.hide '隐藏form1,只是该窗体不见,但还在内存中

我在你上个提问中已经告诉你了 ..
哎.. 不认真看回答

在Form1中只需对Private Sub Command1_Click()作如下修改
Private Sub Command1_Click()
If Text1 = "123456" Then
MsgBox "密码正确,允许登录"
Load Form2
Form2.Show
Form1.Hide '这是加的一句
Else
Text1 = ""
PassNum = PassNum + 1
MsgBox "警告:密码错误"
Text1.SetFocus
End If
End Sub
以下是Form2中的代码
Private Sub Form_Unload(Cancel As Integer)
Form1.Show
End Sub