DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Find if a string contains a second string

Solved!
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
(2,514 Views)
Solution
Accepted by mattia_verona

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
(2,499 Views)

Thank you!

 

Mattia

0 Kudos
Message 3 of 3
(2,467 Views)