|
-
Oct 18th, 2000, 06:58 PM
#1
Thread Starter
Addicted Member
Greetings,
How can i call form_load that is located in form1 from form2 ?
Thanks in advance.
-Lumin
-
Oct 18th, 2000, 07:42 PM
#2
Frenzied Member
Load frmForm1
I am not sure exactly what you want to do.
To load a form, just do "Load frmForm1", where "frmForm1" is the name of the form you want loaded. This will not show the form. In the Form_Load subroutine, to actually show the form do "frmForm1.Show".
I do not think you can execute the Form_Load subroutine for frmForm1 from some other form. If you did, there might be a lot of statements which would not work anyway.
If there is code you want executed when frmForm1 loads, and also want the same code executed when frmForm2 is active, you could put the common code in a Public subroutine in a Code Module. Then call the public subroutine from the frmForm1 load_form subroutine and also call it from code used by frmForm2.
I hope the above helps. If not, post further questions in this Thread.
Live long & prosper.
The Dinosaur from prehistoric era prior to computers.
Eschew obfuscation!
If a billion people believe a foolish idea, it is still a foolish idea!
VB.net 2010 Express
64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.
-
Oct 18th, 2000, 07:43 PM
#3
Fanatic Member
I don't think you can actually call the Load event manually, but it does get called when the form is first loaded. If you load Form1 from Form2, Form1's Load event will be activated.
Code:
'a sample command button in Form2
Private Sub cmdLoadForm1_Click()
Load Form1
End Sub
'inside Form1
Private Sub Form_Load()
MsgBox "Form1 just got loaded", vbOKOnly, "Notice"
End Sub
So if you use this, and press the command button, Form1 will be loaded, and when the load event of it is triggered, the message box will appear.
[Edited by Kaverin on 10-18-2000 at 08:46 PM]
I'm baaaack...
VB5 Professional Edition, VC++ 6
Using a 1 gHz Thunderbird, 256 mb RAM, 40 gb HD system with Win98se
I feel special because I finally figured out how to loop midis: Post link
I'm a fanatic too 
-
Oct 18th, 2000, 08:11 PM
#4
Thread Starter
Addicted Member
thanks.
but form1 is already loaded.. and I need to reload the form_load sub
is there any other way to do this?
-Lumin
-
Oct 18th, 2000, 08:19 PM
#5
Hi,
Why not put all the code in Form_Load of Form1 in a function and call this function from Form2 when u need it.
eg.
Code:
'Form1 code
Private Sub Form_Load()
Call myInit
End Sub
Public Function myInit()
'your code
End Function
'Form2 code
Private Sub Command1_Click()
Call Form1.myInit
End Sub
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Oct 18th, 2000, 08:57 PM
#6
Frenzied Member
Another thot.
Perhaps you should take some of the code out of your Form_Load subroutine and put it into Form_activate or Form_Got_focus subroutine.
Live long & prosper.
The Dinosaur from prehistoric era prior to computers.
Eschew obfuscation!
If a billion people believe a foolish idea, it is still a foolish idea!
VB.net 2010 Express
64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.
-
Oct 18th, 2000, 09:55 PM
#7
Fanatic Member
Just use form_activate()
u can reload the code u want to use when the form is active.
Cheers,
Wen Lie
-
Oct 19th, 2000, 09:49 AM
#8
Thread Starter
Addicted Member
hehehe.. I just realized that I had made this problem much bigger then it originaly was.. I don't know why i didn't think about public functions before..
oh well a reminder is always handy 
Thanks a lot for all the Help evryone!!
-Lumin
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|