Showing results for 
Search instead for 
Did you mean: 

Find if a string contains a second string

Go to solution

Hallo, I need to check if a string variable contains a second string, case sensitive and not. Is there any Diadem/VBS function to do this?

Here an example of what I mean:

If StrContain("pressure","pres") Then

 ChnName = "Pressure"

 ChnUnit = "bar"

End If

0 Kudos
Message 1 of 3
Accepted by topic author mattia_verona
04-16-2019 02:11 AM

Hi mattia_verona,


You can use the InStr() command to see if a matching string is somewhere inside the larger string.  You can use the LCase() or UCase() commands to cast the larger string to lower or upper case to ignore case differences.  If you just wanted to check if the larger string started with the right matching string, you could use the Left() command.


ChName = "MYpreSSuRE"
If InStr(LCase(ChName), "pres") Then
 ChName = "Pressure"
 ChUnit = "bar"
End If
MsgBox ChName

Brad Turpin

DIAdem Product Support Engineer

National Instruments

Message 2 of 3

Thank you!



0 Kudos
Message 3 of 3