Reputation: 483
Dumb question on my part. I have used a '*' many many times, but for the life of me I cannot remember how.
Example: Text in ComboBox1 is iPad Setup Guide 2015 I want to keep it generic in the code (so if it changes to 2016)
Code I have:
If ComboBox1.Text = "iPad Setup Guide" Then
Code I tried:
If ComboBox1.Text = "iPad Setup Guide*" Then
If ComboBox1.Text = "iPad Setup Guide" + "*" Then
What am I forgetting?
Thanks,
Upvotes: 2
Views: 185
Reputation: 43743
I believe you are thinking of VB.NET's Like
operator:
If ComboBox1.Text Like "iPad Setup Guide*" Then
' ...
End If
However, for more powerful pattern matching, you may also want to consider using RegEx:
If RegEx.IsMatch(ComboBox1.Text, "Pad Setup Guide.") Then
' ...
End If
Upvotes: 5
Reputation: 6216
Use Instr
If InStr(ComboBox1.Text, "iPad Setup Guide") > 0 Then
You could also use LEFT if you wanted to only get things starting with the string as opposed to the string appearing in.
Upvotes: 2