Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 2008 > Visual Basic 2008 Essentials
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 13th, 2009, 05:01 AM
Friend of Wrox
Points: 1,075, Level: 12
Points: 1,075, Level: 12 Points: 1,075, Level: 12 Points: 1,075, Level: 12
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2005
Location: , , United Kingdom.
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.
Reply With Quote
  #2 (permalink)  
Old May 13th, 2009, 07:44 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
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.
================================================== =========
Reply With Quote
  #3 (permalink)  
Old May 13th, 2009, 08:53 AM
Friend of Wrox
 
Join Date: Nov 2007
Location: Central Florida, USA.
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
Reply With Quote
  #4 (permalink)  
Old May 19th, 2009, 06:58 AM
Friend of Wrox
Points: 1,075, Level: 12
Points: 1,075, Level: 12 Points: 1,075, Level: 12 Points: 1,075, Level: 12
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2005
Location: , , United Kingdom.
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.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 01:59 PM.


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