VBA用户形式为函数的变量

发布于 2025-02-13 06:02:58 字数 479 浏览 0 评论 0原文

我有以下问题:我有一个用户形式菜单,从那里可以导航到其他页面,我想创建一个“返回按钮”以供每个页面返回菜单。

我尝试创建这个:

Private Sub btnback_Click()
Call back_menu(Actions)
End Sub

Sub back_menu(stage)  'Tried: stage As Object
    Unload stage
    Menu.Show
End Sub

另一个示例:

Sub next_page(from,to)
Unload from
to.show

这个第一现在正在工作,但是每次关闭用户形式时,我都会收到一个错误:

run-type error'13' 输入MISSMATCH

我知道我可以一个一个一个,也可以我们卸载我,但是我还有其他功能,我想使用此方法调用正确的用户形式。

提前致谢

I have the following problem: I have a userform menu, from there I can navigate to other pages, and I want to create a "back button" for each page to return to the menu.

I tried to create this:

Private Sub btnback_Click()
Call back_menu(Actions)
End Sub

Sub back_menu(stage)  'Tried: stage As Object
    Unload stage
    Menu.Show
End Sub

Another example:

Sub next_page(from,to)
Unload from
to.show

This 1st is working now, but everytime I close the userform i got an error:

Run-type error'13'
Type missmatch

I know I could write one by one or I could us the Unload Me, but I have other Functions where I would like to use this method to call the right userform.

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

留一抹残留的笑 2025-02-20 06:02:58

尝试使用hide用户形式的方法

Sub back_menu(stage as UserForm)  'Tried: stage As Object
    stage.hide
    Menu.Show
End Sub
Sub next_page(frmFrom as UserForm, frmTo as UserForm)
  frmFrom.hide
  frmTo.show
end Sub

避免避免使用代码单词的可变名称 - >像to中为i = 1至10

Try using the hide method of the userform

Sub back_menu(stage as UserForm)  'Tried: stage As Object
    stage.hide
    Menu.Show
End Sub
Sub next_page(frmFrom as UserForm, frmTo as UserForm)
  frmFrom.hide
  frmTo.show
end Sub

You shoud avoid variable names that are code words as well --> like to in For i = 1 to 10.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文