|
-
Feb 16th, 2004, 03:34 PM
#1
Thread Starter
Lively Member
Using the same control code for two seperate controls
I hope that title is descriptive enough.
I was showing one of my apps to my coworkers and they offered a little feedback. Basically the user fills out a form and hits the "submit" button. My boss suggested that there should be a submit button on the top as well as the bottom since the form is rather long and people that use lower resolutions might have to scroll down. Rather than argue with my boss, I'll do it.
about 75% of my code is under the submit button control handler. I'd really rather not just cut and paste because that makes maintainabilty a pain. Is there a way to call the same code, without using a module, in a seperate control handler?
I was just going to put in:
Button7_Click()
but they want two parameters to be passed with it. What should I pass? The full declaration is:
Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
-
Feb 16th, 2004, 03:38 PM
#2
Hi.
You can just add another Handles statement after your existing sub.
VB Code:
Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click, Button8.Click
Now this sub will be executed both on button7 and button8 click.
You can keep adding Handles statements for as many buttons as you need.
I wish I could think of something witty to put in my sig...
...Currently using VS2013...
-
Feb 17th, 2004, 02:32 AM
#3
Sleep mode
Or
Call the eventhandler like this :
-
Feb 17th, 2004, 03:37 PM
#4
Thread Starter
Lively Member
Thanks, both of you.
I knew it would be something simple like that.
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
|