FraserOfSmeg
FraserOfSmeg

Reputation: 1148

How can I dynamically reference a control in vb.net

I'm trying to select a control based on setting a variable equal to that control like so:

selectedBox = sender

For reference this is how I declare selectedBox:

Dim selectedBox As PictureBox

What I was hoping to do was something like this:

If selectedBox = picbox then
...

Where picbox is a picturebox passed to the function.

However this doesn't work due to:

Operator '=' is not defined for types 'PictureBox' and 'PictureBox'

So what can I do here?

Upvotes: 1

Views: 79

Answers (1)

A Friend
A Friend

Reputation: 2750

You can use Is like so:

If selectedBox Is picbox Then

Upvotes: 3

Related Questions