停止在关闭和打开用户窗体 _VBA [英] Stop in Close and Open userforms _VBA

查看:42
本文介绍了停止在关闭和打开用户窗体 _VBA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了两个表单.按下按钮 1 打开表格编号 2.通过关闭表格编号 2,显示表格编号 1.但是这个动作只做了一次,第二次就停止了,几乎不起作用.代码哪里有问题?

I created two forms. Pressing the button 1 opens the form number 2. By closing the form number 2, the form number 1 is displayed. But this action is only done once and it stops for the second time and almost does not work. Where does the code have a problem?

代码 Userform1:

Private Sub ShowUserform2_Click()
  UserForm1.Hide
  Unload UserForm1
  UserForm2.Show
End Sub

代码 userform2:

Private Sub UserForm_Terminate()
  UserForm2.Hide
  Unload UserForm2
  UserForm1.Show
End Sub

推荐答案

跳过 formName.Hide 行.它们是不必要的.

Skip the formName.Hide lines. They are unnecessary.

Unload formName 语句之后添加:

Set formName = Nothing

另外,将 otherForm.Show 行置于上述两行之前.

Also, make the otherForm.Show line precede the above two lines.

这篇关于停止在关闭和打开用户窗体 _VBA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆