Solved

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

Posted on 2006-06-21
4
220 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
4 Comments
 
LVL 6

Accepted Solution

by:
manch earned 250 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 250 total points
ID: 16949858
Hi Ruttensoft,

You can check the sender like this:

if sender is Button14 then ...

Cheers!
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

831 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