-
Oct 18th, 2005, 01:19 AM
#1
Thread Starter
Addicted Member
command1_click
Hi;
I want to run command1_click button which inside form1.form from my mdiform.
I wrote something like this
call form1.command1_click
but it doesn't work.
thanks
-
Oct 18th, 2005, 01:23 AM
#2
Re: command1_click
Have you made command1_click Public?
-
Oct 18th, 2005, 01:38 AM
#3
Re: command1_click
You can do it like this:
VB Code:
Form1.Command1.Value = True
Pete
No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.
-
Oct 18th, 2005, 02:30 AM
#4
Re: command1_click
Originally Posted by pnish
You can do it like this:
VB Code:
Form1.Command1.Value = True
I have read somewhere that such method is slower...
-
Oct 18th, 2005, 02:34 AM
#5
KING BODWAD XXI
Re: command1_click
put simply
VB Code:
'Change you command1 click event from
Private sub Command1_click()
'to
Public Sub Command1_click()
-
Oct 18th, 2005, 06:09 AM
#6
Re: command1_click
Originally Posted by levent
Hi;
I want to run command1_click button which inside form1.form from my mdiform.
I wrote something like this
call form1.command1_click
but it doesn't work.
thanks
If you need to execute the code of a control's click event from another form, the easiest and smoothest way to do so is to take the code out of the click event and put it into a Public Sub/Function in a module.
Now you can easily call it from anywhere.
-
Oct 18th, 2005, 06:25 AM
#7
Addicted Member
Re: command1_click
Originally Posted by Hack
If you need to execute the code of a control's click event from another form, the easiest and smoothest way to do so is to take the code out of the click event and put it into a Public Sub/Function in a module.
Now you can easily call it from anywhere.
I absolutely agree with this, especially if you're plan on calling the code alot.
and cover!
-
Oct 18th, 2005, 06:30 AM
#8
KING BODWAD XXI
Re: command1_click
Just remember to update it when you update the other sub. Thats the only trouble with that method. Pick and choose (thats what I do) if its likely to become different seperate it off if its definetely going to be identicle use the idea you are using
-
Oct 18th, 2005, 06:34 AM
#9
Frenzied Member
Re: command1_click
you need to make it public:
VB Code:
Public Sub Command1_click()
-
Oct 18th, 2005, 07:03 AM
#10
Re: command1_click
Originally Posted by BodwadUK
Just remember to update it when you update the other sub. Thats the only trouble with that method. Pick and choose (thats what I do) if its likely to become different seperate it off if its definetely going to be identicle use the idea you are using
No, just use 1 subroutine/function and use this one in your CommandButton1_Click event as well as from another form.
why can't programmers keep and 31 Oct and 25 dec apart. Why Rating is Useful
for every question you ask provide an answer on another thread.
-
Oct 18th, 2005, 08:27 AM
#11
KING BODWAD XXI
Re: command1_click
hmm fair enough but it means running around when debugging
-
Oct 18th, 2005, 08:39 AM
#12
Re: command1_click
Originally Posted by BodwadUK
hmm fair enough but it means running around when debugging
You would do all your debugging in one spot. The Sub/Function.
The various places that call it would not necessarily have to be changed/checked unless you needed to change any passed parameters.
-
Oct 18th, 2005, 08:59 AM
#13
KING BODWAD XXI
Re: command1_click
I have to reuse forms alot so it becomes problematic if you start intercrossing modules and forms in a huge mesh
-
Oct 18th, 2005, 04:24 PM
#14
Re: command1_click
Originally Posted by dee-u
I have read somewhere that such method is slower...
Oh... I read somewhere that it's much faster Anyway, how fast (or slow) is clicking a command button???
I agree that if you have code that is being called from several different places, it makes more sense to place it in it's own sub. It's generally not a good idea to fill control event handlers with heaps of code anyway. Gets very messy.
Pete
No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.
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
|