Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2008 > Visual Basic 2008 Essentials
|
Visual Basic 2008 Essentials If you are new to Visual Basic programming with version 2008, this is the place to start your questions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2008 Essentials section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 13th, 2009, 05:01 AM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Default Multiple Button Clicks Handled By One Sub

Hi,
I'm making an EPOS (Electronic Point of Sale) for a pub and it's all going to be touch screen inputting. So i will have alot of buttons, so i thought and i'm pretty sure i have made one sub for all like below
Code:
Private Sub Multiple_Button(ByVal sender As Button, ByVal e As System.EventArgs) Handles Button1.Click . . etc . . 'All buttons here
'Any Code Here
End Sub
But vb doesn't like it what so ever.

Any Ideas?
__________________
Apocolypse2005, I'm a programmer - of sorts.
 
Old May 13th, 2009, 07:44 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

2 things.

What error do you receive??

Also, if you are having a lot of buttons, I would strongly suggest against it, Or you will do a big select case to know what to do in each case???
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old May 13th, 2009, 08:53 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 207
Thanks: 2
Thanked 15 Times in 15 Posts
Default I think...

Your issue is your handler

You are specifying the handler in the procedure when you should be adding the handler to the object.

Instead of this:
Code:
Private Sub Multiple_Button(ByVal sender As Button, ByVal e As System.EventArgs) Handles Button1.Click
do this
Code:
Private Sub Multiple_Button(ByVal sender As Button, ByVal e As System.EventArgs)
and then use addhandler to add a handler to the buttons you want to use this sub.

you can do this in the load
Code:
addhandler Button1.Click, addressof Multiple_Button
addhandler Button2.Click, addressof Multiple_Button
__________________
Jason Hall

Follow me on Twitter @jhall2013
 
Old May 19th, 2009, 06:58 AM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Default The real answer, haha

Nope nope nope, your all wrong. Ha, nah its just that you dim the sender as an object NOT button then inside the function because i know that they're all buttons then i can make variable inside the function by type of Button. then equate the sender to the button then from there on i can manipulate it how i like!

Thanks for the comments though, they did jog some memory!

Cheers
__________________
Apocolypse2005, I'm a programmer - of sorts.





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Detect when the user clicks on close button nanajee Javascript 2 March 4th, 2009 10:04 PM
How to count the button clicks bex ASP.NET 2.0 Basics 2 February 13th, 2009 05:34 AM
fired event Sorting which wasn't handled fantef ASP.NET 2.0 Basics 0 July 27th, 2006 10:05 AM
Refresh Page when User Clicks on Back Button testsubject Visual Studio 2005 1 June 26th, 2006 03:46 AM
setting event handled to true sajid C# 3 April 27th, 2005 12:02 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.