VBA-用户窗体新实例 [英] VBA - Userform new instance

查看:64
本文介绍了VBA-用户窗体新实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我有一个主要的用户窗体,我在其中进行所有计算,并希望将其显示在图像窗体上.我尝试使用:

So I have a main userform where I do all my calculations and I want to display them on my image forms. I tried to use:

Dim newInstance As New diagramGUI
newInstance.Show vbModeless

但是我不能从主要用户表单访问数据.有什么解决方法吗?

but then I cant access the data from the main userform. Is there any workaround for this?

推荐答案

您需要在 diagramGUI 用户窗体中添加一个公共变量,以指向MainUserForm的实例.

You need to add a public variable in the diagramGUI userform to point the the instance of MainUserForm.

将此行添加到 diagramGUI 代码模块

 Public Controller as MainUserForm 

然后实例化然后创建新的 diagramGUI

Then set the reference from the MainUserForm after you instantiate then new diagramGUI

 Dim newInstance As New diagramGUI
 Set newInstance.Controller = Me
 newInstance.Show vbModeless

这篇关于VBA-用户窗体新实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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