我怎样才能加载“未来”?在使用表单控件之前?详细解释:
我正在将 vb6 程序迁移到 vb.net。理解这个问题需要的基础知识是,有两种形式需要相互通信,frmInput1和frmInput2。我有以下代码(在 frmInput1 后面),它检查 frmInput2 上的文本框是否具有特定值,似乎是在加载之前:
If frminput2.lblInputMac.Text <> "(no filename)" Then
Dim calc As CalculationCaster = New CalculationCaster
Call calc.FillMac()
cmdNext.Enabled = False
frminput2.FraInner.Enabled = True
当我运行它时,我在 If 行上收到以下错误:
"Object reference not set to an instance of an object."
我认为这意味着 frmInput2 中的对象尚未加载。在显示之前如何加载 frmInput2?
谢谢尼克
I am performing a migration on a vb6 program, to vb.net. The basic knowledge you need to understand this question is that there are two forms that need to talk to each other, frmInput1 and frmInput2. I have the following code (behind frmInput1) that checks if a textbox on frmInput2 has a certain value, seemingly before it has loaded:
If frminput2.lblInputMac.Text <> "(no filename)" Then
Dim calc As CalculationCaster = New CalculationCaster
Call calc.FillMac()
cmdNext.Enabled = False
frminput2.FraInner.Enabled = True
I get the following error on the If line when i run it:
"Object reference not set to an instance of an object."
Which i assume means that the object in frmInput2 has not been loaded yet. How can i load frmInput2 before i show it?
Thanks
Nick
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
frminput2
可能是类型 frminput2 的隐式全局实例。如果您在 VB6 中定义名为
MyForm
的表单类型,平台会自动创建同名的隐式全局变量MyForm
。每当您在代码中引用此变量时,它都会自动为您加载表单的实例。就好像你有这段代码一样。
frminput2
is probably the implicit global instance of the type frminput2.If you define a form type in VB6 called
MyForm
, the platform automatically creates an implicit global variable of the same nameMyForm
. Whenever you refer to this variable in code, it automatically loads an instance of the form for you.It's rather as if you had this code.
此时,您应该能够在不显示表单的情况下在表单之间进行通信。您不应在未显式实例化表单的情况下引用表单。
At this point, you should be able to communicate between forms without them being displayed. You should not reference forms without explicitly instantiating them.
创建表单的实例。
然后您可以使用窗体上的任何属性、方法或控件。
Create an instance of the form.
Then you can use any properties, methods, or controls on the form.