Click here to Skip to main content
15,885,537 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Dear Friend,

I am trying to write code as the following-



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

         Case TextBox

         Case ComboBox

         Case Label

    End Select
Next




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

Regards
SKPaul
Posted
Updated 11-Jul-18 23:05pm
v2

You should use If Else statement like this

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


If you want to use Select Case then you can do this as
VB
Select Case True
        Case TypeOf ControlObject Is TextBox
        Case TypeOf ControlObject Is Button
End Select
 
Share this answer
 
Comments
Saumitra Kumar Paul 10-Aug-11 2:06am    
Many Many Many Thanksssssss, Dear Suresh
Suresh Suthar 10-Aug-11 2:08am    
Most welcome dear...
Abhinav S 10-Aug-11 2:14am    
Good answer. 5.
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 :)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900