vb6 调用形式,名称包含在数组中
我有一个名为菜单的数组。它包含每个元素的表单名称。
我怎样才能动态地调用它们?
例如,如果 Menus(1) = "Login" 和 Menus(2) = "Logout" 我需要说,
Login.Show
但我想使用数组名称来做到这一点。我显然不能这样做:
Menus(X).Show
这在 VB 中可能吗?或者有办法解决这个问题吗?
提前致谢!
I have an Array named Menus. It contains a form name per element.
How can I call them dynamically?
For example, if Menus(1) = "Login", and Menus(2) = "Logout" I need to say
Login.Show
but I want to do this using the Array name. I clearly can't do this:
Menus(X).Show
Is this possible in VB or is there a way around this?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您本质上想做的是使用表单的名称来实例化并加载表单。
一种方法是将包含表单名称的字符串传递给表单
Collection
的Add
函数:或者,使用 VB6 的 CallByName 功能:
What you're essentially trying to do is use a form's name to instantiate and load a form.
One way to do this is to pass a string with your form's name to the Form
Collection
'sAdd
function:Or, using VB6's CallByName Function:
您可以使用以下代码:
You can use the following code: