|
-
May 6th, 2001, 04:51 AM
#1
Thread Starter
Member
calling subs
does anyone know how to call sub from another form?
for example, i am working with form 1, but i need to call a command1_click() from form2, does anyone know how to do this?
-emptywords
-
May 6th, 2001, 05:20 AM
#2
Dead easy.
There are 2 ways to do this...
Change the Command1_Click Event to Public instead of Private. Then in Form2 use...
Code:
Call Form1.Command1_Click
Or, you could dump all the code from that event into a public sub inside a module, then you can call that code from any form you like.
The second way is safer, but make sure it doesnt throw any of your variables out of scope.
-
May 6th, 2001, 08:01 PM
#3
You could also set it's Value property to True, which will also call the Command1_Click event.
Code:
Form2.Command1.Value = True
-
May 7th, 2001, 02:34 PM
#4
Matthew, yeah but why do it the easy way when you can risk throwing all kinds of bugs into the program with my method! 
ps. Won't your way force a refresh of the button's graphical DC clipping region?
-
May 7th, 2001, 04:56 PM
#5
Monday Morning Lunatic
Is that a particular problem?
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
May 7th, 2001, 06:57 PM
#6
Originally posted by Matthew Gates
You could also set it's Value property to True, which will also call the Command1_Click event.
Not all controls have a Value property. Also, What if the sub being accessed was not an sub linked to an object?
-
May 7th, 2001, 07:33 PM
#7
Only talkin' about a Command Button here .
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
|