Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

lots of "handles x, y, z...." => Question

Posted on 2006-06-21
4
Medium Priority
?
227 Views
Last Modified: 2010-04-23
Hello

I have lots of buttons, and if I click on one, and I then press a key (1-9), the name of the button should change to the key-value.

I can do it like this:

Private Sub Button14_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Button14.KeyDown, Button15.KeyDown, Button16.KeyDown
        If e.KeyCode > 48 And e.KeyCode < 58 Then
            Button14.Text = e.KeyCode - 48
        End If
    End Sub

But in this example I have 3 buttons "handled", but how can I read in the code which button is "active"?

Thanks!

Sven
0
Comment
Question by:Ruttensoft
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 6

Accepted Solution

by:
manch earned 1000 total points
ID: 16949467
Write in the following way :

Private Sub Button14_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Button14.KeyDown, Button15.KeyDown, Button16.KeyDown

       Dim pObjBtn as Button

       pObjBtn = Ctype(Sender, Button)

          If e.KeyCode > 48 And e.KeyCode < 58 Then
                pObjBtn.Text = e.KeyCode - 48
        End If

    End Sub
0
 
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 1000 total points
ID: 16949858
Hi Ruttensoft,

You can check the sender like this:

if sender is Button14 then ...

Cheers!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question