From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

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,544 Views)
Solution
Accepted by topic author 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,529 Views)

Thank you!

 

Mattia

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