选择案例类型可以控制吗? [英] Select Case TypeOf Control Possible?

查看:61
本文介绍了选择案例类型可以控制吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友,



我正在尝试编写如下代码 -







Dear Friend,

I am trying to write code as the following-



For Each ControlObject As Control In Me.Controls
    Select Case TypeOf ControlObject

         Case TextBox

         Case ComboBox

         Case Label

    End Select
Next









但它表示预计在第二行之后。是否有任何技术可以做到这一点?



问候

SKPaul





But it says that "Is expected" after the second line. Is there any technique to do it?

Regards
SKPaul

推荐答案

您应该使用如果Else 这样的声明



You should use If Else statement like this

If TypeOf ControlObject Is TextBox Then
ElseIf TypeOf ControlObject Is Button Then
End If





如果你想使用 Select Case 那么你可以这样做



If you want to use Select Case then you can do this as

Select Case True
        Case TypeOf ControlObject Is TextBox
        Case TypeOf ControlObject Is Button
End Select


我看,这是一个老帖子:)

如果有人正在寻找它,在我的情况下:



I see, this is an old post :)
If someone is looking for it, in my case:

Select Case val.GetType
			Case GetType(<yourType>)

		End Select





为我工作:)



worked for me :)


这篇关于选择案例类型可以控制吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆