distante
distante

Reputation: 7005

Get Own control values in visual basic 10

I'm looking for a way to get the data of control (in this case a Trackbar) inside the trackbar itself.

I got this:

Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
    Label1.Text = TrackBar1.Value
End Sub

But I want to replace that "trackBar1." with something like

    Label1.Text = THIS_CONTROL.Value

Is this possible in Vb10 ?

Thanks

Upvotes: 0

Views: 83

Answers (1)

Joel Coehoorn
Joel Coehoorn

Reputation: 415745

Use the sender argument:

Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
    Dim THIS_CONTROL As TrackBar = DirectCast(sender, TrackBar)
    Label1.Text = THIS_CONTROL.Value
End Sub

Upvotes: 1

Related Questions