if (x like *Y) then?

Banaticus

Registered User.
Local time
Today, 01:13
Joined
Jan 23, 2006
Messages
153
Is it possible to get some sort of SQL Like operator in a VB if/then statement?

Currently, on one form, some items have a tag "Vanity Object" on them. When a command button is clicked, the vanity objects are hidden.
Code:
For i = 0 To Me.Controls.Count - 1
	If Me(i).Tag = "Vanity Classes" Then
		Me(i).Visible = Hidden
	End If
Next i
I'd like to continue with this practice. I'd like to give some objects a "PinkPanther" tag (not really the name, I'm not yet sure what I'll call it). So, objects would have the following tags:
'nothing
"Vanity Object Pink Panther"
"Vanity Object"
"Pink Panther"

I'd like to change my code to be something on the order of:
If Me(i).Tag Like "*Vanity Objecty*" Then...

I realize that this can't be done with a normal If/Then statement. But, perhaps it could be done with some other statement? I mean, I just learned about IIf a few days ago, who knows what else might be out there?
 
You could use the InStr function to check if the required string is contained in the tag. See the Access help file for details on the Instr function.
 

Users who are viewing this thread

Back
Top Bottom