Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

linking VB.net forms

Status
Not open for further replies.

hazeljean

Technical User
Aug 23, 2003
16
US
Still having difficulty linking to a "subform". Would appreciate any ideas. I have a main form with a variable number of check boxes. If the users selects a checkbox, I need to open another form with checkboxes etc. I may have several levels of forms.

Thanks
 
I am not sure what your final goal of your project is but you can declare all your forms in a module using Protected Friend and then launch you program in sub main. This will give you access to all your forms from anywhere in your app.

It is late let me know if you need a code example.

DotNetDoc
M.C.S.D.
---------------------------------------

Tell me and I forget. Show me and I remember. Involve me and I understand.
- Anonymous Chinese Proverb

-----------------------------------

If you can't explain it simply, you don't understand it well enough.
- A. Einstein





 
I would be curious to see a code example. I am new to .net and have never used sub main to launch an application. I have an app with 2 forms, where form1 is where 95% of the action is at, but form2 has a timer event that needs to load/start and fire. Within that timer is the code that is executed for form2. Basically, I need both forms to load at startup. I have tried dim'ing the forms in sub main, and .show and .showdialog'ing them, but the forms load, execute form_load code, then exit.
 
I would be more than happy to give you a code example. But first lets make sure you are doing it the most efficient way. What exactly are you using a timer in form two for? Give me a little background and I might be able to give you a better solution.



DotNetDoc
M.C.S.D.
---------------------------------------

Tell me and I forget. Show me and I remember. Involve me and I understand.
- Anonymous Chinese Proverb

-----------------------------------

If you can't explain it simply, you don't understand it well enough.
- A. Einstein





 
This is for a messaging application using sockets. Basically frmSend (form1) is used to select who to send a message to, and then frmReceive (form 2) receives the messages. Inside the timer event is where it checks the socket to see if there is a socket request and process it if there is one.
 
Okay, I've handled this from a different direction.

I'm using the first form as the startup, and have put the timer there, with the appriate code to check the socket. I then call a sub in the second form, passing it the message and other items and process it there.

 
I need code example.
I have 2 situations.

1. when form is opened it immediately must call some other forms(a variable number of sub-forms)

2. When a certain checkbox is checked I need to call another form.

Thanks.
 
There are events that will fire for each of the situations that you list.
1: Is there any reason you can't load the sub-forms from the form_load event?
2: The CheckBox1_CheckedChanged event should handle the other.
If you need code for either one of these solutions, let me know and I'll work something up for you.

As an aside, I'd be interested in seeing code to launch multiple forms from sub main() as well. I don't have a need to do that at this time, but you never know.
 
situation 1
I believe there is a timing problem.
I do not know form names at form-load time.
I read a text file that contains the names of the subforms.
Names can be different everytime.
(I am also new at VB and am stumling through by trial and error.)
situation 2
I know how to do the statement you mentioned above. I can open a form but it is blank. I need to dynamically load a form whose name is read in via a text file (if a certain checkbox is checked). I am not able to load the second form in dynamically.

thanks
 
At what point do you know the form name? In both cases, you can simply load the form as soon as you know the name.
 
My problem is "finding" the sub-form I am loading.
Does it have to be resident in memory? An executable?
I have over a 1000 candidate forms; any one may be called by any other form.

Thanks
 
Over 1000 forms? Are you talking about windows forms within your VB project? If not, can you be more specific by what you mean as by "forms"?
 
They are vb forms.
I am generating forms dynamically depending on the contents of a text file.
Each text file(over 1000) is used to creat checkboxes(variable number).
Some forms always open up other forms(indicated in text file.)
Other forms are opened only when a specific checkbox is checked on the main form.
Each subform returns text output to the calling form. All text is then output to a text file as a "report"
I have all the logic working to parse text files etc. etc.
The problem is having the main form and sub-form showing on the screen simultaneously.
Maybe it is not possible?
Thanks
 
I'm relatively new to .net myself... I would guess what you're attempting isn't possible, but definitely don't take my word for it. Others here might be able to help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top