PDA

View Full Version : [SOLVED:] Like Operator



ksilenio
10-04-2020, 11:05 AM
Hi everyone .
I have store a string in a variable (var1="AA-Example-1")
In an "if" statement i want to take only the "AA" e.g


If "AA" Like "#.. (var1) ???? then
....
end if

How can i write this statement with the LIKE oparator?

PS I want the LIKE search in var1 for the "AA"

Thank you for your time
Kostas

Paul_Hossler
10-04-2020, 01:36 PM
InStr() might be easier and would be faster, but here's Like examples



Sub test()
Dim var1 As String
var1 = "AA-Example-1"
If var1 Like "AA*" Then MsgBox "Yes"
var1 = "ZZZ-AA-Example-1"
If var1 Like "*AA*" Then MsgBox "Yes"
End Sub

ksilenio
10-05-2020, 11:33 AM
OK Thank you Paul