启动表单的名称 [英] Startup Form's Name
问题描述
这可能是一个愚蠢的问题,但我已经让自己感到困惑。
我的应用程序有两种形式,form1和form2。 form1是
propers中的启动对象。 form1中的事件实例化form2。
将myForm调暗为HardwareStore
myForm = New HardwareStore
myForm.Show()
我明白我的form2可以被引用
myForm.blah
什么是表格form1的名称,以便我可以从form2引用它
(myForm)?
form1.blah
不行。
对不起这个基本问题,但我想在这里学习,哈哈哈。
伯尼
This is probably a silly question, but I''ve gotten myself confused.
My app has two forms, form1 and form2. form1 is the start up object in the
propers. An event in form1 instantiates form2.
Dim myForm as HardwareStore
myForm = New HardwareStore
myForm.Show()
I understand that my form2 can be referenced by
myForm.blah
What is the form name for form1 so that I can reference it from form2
(myForm)?
form1.blah
Doesn''t work.
Sorry for such a basic question, but I''m trying to learn here, hahaha.
Bernie
推荐答案
你真的没有两种形式。你有一个表单类''HardwareStore''
和该类'myForm'的实例。
设置启动对象时你会选择HardwareStore和
运行时将生成它的一个实例并显示该实例。你需要明确地创建和显示表格。
根据上面的行位置,他们将永远不会
运行或者你可能有两个硬件实例显示。
启动VB.Net应用程序有几种不同的方法。
简单的开始。
定义HardwareStore表单。将其标记为您的启动对象。运行
应用程序,它将显示。
更复杂的开始。
创建一个模块,比如HardwareLoader,和把一个子main()放在里面
模块HardwareLoader
public sub main(args()as string)
Dim mainForm作为新的HardwareStore
Application.Run(mainForm)
end sub
结束模块
将HardwareLoader设置为启动对象。运行应用程序。
hth,
Alan。
You really don''t have two forms. You have a form class ''HardwareStore''
and an instance of that class ''myForm''.
When setting a startup object you would select HardwareStore and the
runtime will generate an instance of it and display that instance. You
need to explictly create and show the form.
Depending upon where the lines above are placed either they will never
be run or you may have two instances of HardwareStore showing.
There are a few different ways to start a VB.Net application.
For a simple start.
Define the HardwareStore form. Mark it as your startup object. Run the
application and it will show.
For a more complicated start.
Create a module, say HardwareLoader, and put a sub main() in it
Module HardwareLoader
public sub main(args() as string)
Dim mainForm as new HardwareStore
Application.Run(mainForm)
end sub
end module
Set HardwareLoader as the startup object. Run application.
hth,
Alan.
您可以在表单2中设置属性例如myform1并设置为启动表格
as;
dim myform2 as nrew form2
myform2.myform1 = me
myform2.show或myform2.showdialog
-
休斯顿的丹尼斯
" Bernie亨特"写道:
You can set a property in Form 2 such as myform1 and set to the startup form
as;
dim myform2 as nrew form2
myform2.myform1 = me
myform2.show or myform2.showdialog
--
Dennis in Houston
"Bernie Hunt" wrote:
这可能是一个愚蠢的问题,但我已经弄糊涂了。
我的应用程序有两种形式,form1和form2。 form1是
propers中的启动对象。 form1中的事件实例化form2。
将myForm调暗为HardwareStore
myForm = New HardwareStore
myForm.Show()
我明白我的form2可以引用
myForm.blah
form1的表单名称是什么,以便我可以从form2
(myForm)引用它?
form1.blah
不工作。
抱歉这个基本问题,但我想在这里学习,哈哈哈。
Bernie
This is probably a silly question, but I''ve gotten myself confused.
My app has two forms, form1 and form2. form1 is the start up object in the
propers. An event in form1 instantiates form2.
Dim myForm as HardwareStore
myForm = New HardwareStore
myForm.Show()
I understand that my form2 can be referenced by
myForm.blah
What is the form name for form1 so that I can reference it from form2
(myForm)?
form1.blah
Doesn''t work.
Sorry for such a basic question, but I''m trying to learn here, hahaha.
Bernie
按照您的指导方针,我现在有;
模块主页>
Public Sub main()
Dim myFormStartup As New StartUp
Application.Run(myFormStartup)
End Sub
课程启动
将myFormHardware调暗为Hardware_Store
将myFormHardwareStatus调暗为布尔值
Private Sub StartUp_Load (ByVal sender As System.Object,ByVal e As
System.EventArgs)处理MyBase.Load
myF ormHardwareStatus = False
End Sub
Private Sub StartUp_Load(ByVal sender As System.Object,ByVal e As
System.EventArgs )处理MyBase.Load
myFormHardwareStatus = False
myFormHardware = New Hardware_Store
myFormHardware.Show()
End Sub
公共函数getMyFormHardwareStatus()As Boolean
返回myFormHardwareStatus
结束函数
Public Sub setMyFormHardwareStatus(ByVal Status As Boolean)
myFormHardwareStatus = Status
End Sub
Class HardwareStore
Private Sub Hardware_Store_Load(ByVal sender As System.Object,ByVal
$ b $ as As System.EventArgs)处理MyBase.Load
''此行是我所在的位置我有问题
''错误说MyFormStartup没有被宣布
myFormStartup.setMyFormHardwareStatus(True)
结束子
问题是试图引用我在sub Main()中实例化的myFormStartup
中的函数或子。
我能错过的是什么访问myFormStartup中的一个函数?
谢谢,
伯尼
" AlanT" <人******* @ users.com>在新闻中写道:1144283866.510955.33080
@ i39g2000cwa.googlegroups.com:
Following your guidelines, I now have;
Module Main
Public Sub main()
Dim myFormStartup As New StartUp
Application.Run(myFormStartup)
End Sub
Class Startup
Dim myFormHardware As Hardware_Store
Dim myFormHardwareStatus As Boolean
Private Sub StartUp_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
myFormHardwareStatus = False
End Sub
Private Sub StartUp_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
myFormHardwareStatus = False
myFormHardware = New Hardware_Store
myFormHardware.Show()
End Sub
Public Function getMyFormHardwareStatus() As Boolean
Return myFormHardwareStatus
End Function
Public Sub setMyFormHardwareStatus(ByVal Status As Boolean)
myFormHardwareStatus = Status
End Sub
Class HardwareStore
Private Sub Hardware_Store_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles MyBase.Load
'' This line is where I''m having the problem
'' The error says MyFormStartup is not declared
myFormStartup.setMyFormHardwareStatus(True)
End Sub
The problem is trying to reference a function or sub in the myFormStartup
that I instantiated in the sub Main().
What am I missing to be able to access a function in myFormStartup?
Thanks,
Bernie
"AlanT" <al*******@users.com> wrote in news:1144283866.510955.33080
@i39g2000cwa.googlegroups.com:
你真的没有两种形式。你有一个表单类''HardwareStore''
和该类'myForm'的实例。
设置启动对象时,你会选择HardwareStore和
运行时将生成它的一个实例并显示该实例。您需要明确地创建并显示表单。
根据上面的行的位置,它们将永远不会被运行,或者您可能有两个HardwareStore实例。
启动VB.Net应用程序有几种不同的方法。
一个简单的开始。
定义HardwareStore表单。将其标记为您的启动对象。运行
应用程序,它将显示。
更复杂的开始。
创建一个模块,比如HardwareLoader,并在其中放置一个子main()
模块HardwareLoader
公共子主(args()为字符串)
将mainForm作为新的硬件存储器调用
Application.Run(mainForm)>
end sub
结束模块
将HardwareLoader设置为启动对象。运行申请。
hth,
Alan。
You really don''t have two forms. You have a form class ''HardwareStore''
and an instance of that class ''myForm''.
When setting a startup object you would select HardwareStore and the
runtime will generate an instance of it and display that instance. You
need to explictly create and show the form.
Depending upon where the lines above are placed either they will never
be run or you may have two instances of HardwareStore showing.
There are a few different ways to start a VB.Net application.
For a simple start.
Define the HardwareStore form. Mark it as your startup object. Run the
application and it will show.
For a more complicated start.
Create a module, say HardwareLoader, and put a sub main() in it
Module HardwareLoader
public sub main(args() as string)
Dim mainForm as new HardwareStore
Application.Run(mainForm)
end sub
end module
Set HardwareLoader as the startup object. Run application.
hth,
Alan.
这篇关于启动表单的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!