[VBA] Equivalent function to "Starts with"

Bully -  
 Anonymous user -
Hello everyone!

So, I have a variable that can contain different types of values such as "TPV C4S", "TPV C5C", "Software Press", "Library Software".

And I would like to translate this into VBA:

IF variable 'Starts with' "TPV" THEN
Display Variable = "TPV"
ELSE IF .....

But I don't know how to translate "starts with." I searched online but couldn't find the necessary information.

A big thank you to those who can help me and have a great day!

4 réponses

lami20j Posted messages 21506 Registration date   Status Modérateur, Contributeur sécurité Last intervention   3 570
 
Sub a() Dim val As String val = "TPV dskjfkjsd sdjkjf" If val Like "TPV*" Then ' TPV 'is followed by zero or more characters MsgBox "ok" Else MsgBox "does not match!" End If End Sub
5