Pass Control.Name to Sub from which it is called

I have a sub that is call from many diferant textboxes.  I need to pass the control name to the called sub.

Private Sub TrigTSAWavTextBox_Validating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TrigTSAWavTextBox.Validating
 
       ChkForNumber(This.control.name) 'Pass the Control.Name from this Sub
 End Sub

Private Sub ChkForNumber(ByVal TxtBox As Control)
        If Not IsNumeric(TxtBox.Text) Then
            TxtBox.ForeColor = Color.Red
            MsgBox("Enter only numbers for this field." & vbCrLf & "This field also cannot be blank." _
                   & vbCrLf & "Example .. -3, -2, -1, 0, 1, 2, 30", MsgBoxStyle.Exclamation, "Flight Status User Input Error")
            TxtBox.ForeColor = Color.Black
            TxtBox.Text = ""
        End If
    End Sub

Since I do not know which textbox is calling the SubChkForNumber I need to pass the textbox.name.
buzzcarterAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

purquizCommented:
Hi.
I'm not sure, haven't used the 2008 version, but I noticed you defined a Sub that takes a control as an argument:

...
Private Sub ChkForNumber(ByVal TxtBox As Control)
...

but when you call it you are passing a string, not a control:

...
ChkForNumber(This.control.name) 'Pass the Control.Name from this Sub
...

Anyways, sorry if I'm wrong, but as I said I haven't worked with 2008 yet.

Greetings from Argentina;

Pablo
0
dentabCommented:
You mean sender.name?

e.g.
  ChkForNumber(Sender.Name)

I dont have .net instaleld on this machine to check, but I am sure it is as simple as that.
0
dentabCommented:
and for your example you dont want the name...

You want

ChkForNumber(Sender)

To actually reference the control
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
buzzcarterAuthor Commented:
Prefect, that saves alot of work.  Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.