在VB中如何判断control类型?

来源:百度知道 编辑:UC知道 时间:2024/05/12 20:07:10
在VB中自定义一个函数,其中有个参数strItemID As VB.Control
想在该函数中判断传进来的strItemID 类型(是CommandButton?DirListBox?还是其他?),如何做呢?

用函数 typename(a)
返回值为变量a的数据类型字符串.
当然,如果你只是定义了a as control,而没有给a附值,那函数的返回值将会为nothing.

If typeof textbox1 is TextBox then
msgbox "是 TextBox"
else
msgbox "不是 TextBox"
end if