如何在vb.net中动态引用控件

如何在vb.net中动态引用控件,vb.net,controls,picturebox,Vb.net,Controls,Picturebox,我试图通过设置一个等于该控件的变量来选择控件,如下所示: selectedBox = sender 以下是我如何声明selectedBox以供参考: Dim selectedBox As PictureBox 我希望做的事情是这样的: If selectedBox = picbox then ... 其中picbox是传递给函数的picturebox 但是,这不起作用,因为: Operator '=' is not defined for types 'PictureBox' and 'P

我试图通过设置一个等于该控件的变量来选择控件,如下所示:

selectedBox = sender
以下是我如何声明selectedBox以供参考:

Dim selectedBox As PictureBox
我希望做的事情是这样的:

If selectedBox = picbox then
...
其中picbox是传递给函数的picturebox

但是,这不起作用,因为:

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

那么我能在这里做什么呢?

你可以像这样使用
Is

If selectedBox Is picbox Then