停止在关闭和打开用户表单_VBA

时间:2018-10-10 15:32:15

标签: excel vba userform

我创建了两种形式。按下按钮1将打开表格编号2。通过关闭表格编号2,将显示表格编号1。但是此操作仅执行一次,它第二次停止,几乎不起作用。代码在哪里有问题?

代码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

2 个答案:

答案 0 :(得分:0)

跳过PagingProvider<Employee> provider = new PagingProvider<Employee>(context.Employees); provider.FilterExp = (employee, filterText) => employee.FullName.Contains(filterText); return provider.GetResults(); 行。它们是不必要的。

formName.Hide语句之后添加:

Unload formName

另外,将Set formName = Nothing 行置于上述两行之前。

答案 1 :(得分:0)

尝试以下代码:

代码Userform1:

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

代码userform2:

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
    UserForm1.Show
End Sub