|
-
Feb 17th, 2005, 01:06 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED]How to make a button click event happen from another sub?
I have a sub procedure that I want to have act like it can click a button to make the button's procedures for the click event fire.
Is there an easy way to do this or should I go about this differently?
Thanks in advance.
Last edited by gjon; Feb 17th, 2005 at 11:06 AM.
-
Feb 17th, 2005, 01:11 AM
#2
Re: How to make a button click event happen from another sub?
Post the code procedures. There are a few different ways. If its from another buttons click
event you can just call the other command buttons event passing the sender and e arguments
from the first buttons received arguments.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 17th, 2005, 01:46 AM
#3
Thread Starter
Hyperactive Member
Re: How to make a button click event happen from another sub?
VB Code:
Private Sub btnTimeChnge_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTimeChnge.Click
timerVariable = tbxTimerLength.Text.ToString
tmrLoadPge.Interval = 60000 * timerVariable
End Sub
Was thinking of having the timer call the button click.
But then I realized I could use the timer to loop.
VB Code:
Private Sub tmrLoadPge_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrLoadPge.Tick
tmrLoadPge.Stop()
Process.Start(Me.lnkWebPages.Text)
tmrLoadPge.Start()
End Sub
But I would still like to see it the way I originally asked about it.
Thanks in advance.
-
Feb 17th, 2005, 03:21 AM
#4
Hyperactive Member
Re: How to make a button click event happen from another sub?
Something like this should do you:
VB Code:
Private Sub tmrLoadPge_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrLoadPge.Tick
tmrLoadPge.Stop()
Process.Start(Me.lnkWebPages.Text)
btnTimeChnge_Click(tmrLoadPge, e)
tmrLoadPge.Start()
End Sub
It's just like calling any other method. You specify the name of the procedure and pass the required arguments. In this case, the object that is calling the event tmrLoadPge and then an event arguments class. The simplest way is to pass the event arguments of the timer event as per the example above.
You could also use
VB Code:
btnTimeChnge_Click(tmrLoadPge, New EventArgs)
This passes a new instance of the basic eventargs class.
Some events have other types of eventargs classes associated with them so you may find things like calling a keypress event from code a little more complex, but here you're just fine with the default class.
Hope this is what you're looking for.
Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind.
Dr. Seuss 
-
Feb 17th, 2005, 06:14 AM
#5
PowerPoster
Re: How to make a button click event happen from another sub?
Hi,
Or
Button1.PerformClick()
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Feb 17th, 2005, 06:18 AM
#6
Hyperactive Member
-
Feb 17th, 2005, 11:06 AM
#7
Thread Starter
Hyperactive Member
Re: How to make a button click event happen from another sub?
LOL, awesome guys. Thanks. I will try to understand the passing of arguments by playing with your sample too.
Thanks again.
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
|