/build/static/layout/Breadcrumb_cap_w.png

Scripting Question


VBScript to compare more than 2 strings

03/05/2014 5276 views

String1 ="text"

String2 ="text"

String3 ="text"

String4 ="text"

String5 ="text"

if String1 and String2 and string3 and string4 and string5 = "text" then

msgbox "equal"

else

msgbox "not equal"

end if

The above syntax does not work well. do you have any other way to compare multiple strings?

Answer Summary:
0 Comments   [ + ] Show comments

Comments



Community Chosen Answer

2

Hi

to compare multiple string :-

take an array

a=Array("text","text","text","text","monday","sunday")

b=Filter(a,"")

for each x in b

if strcomp(x,"test",vbTextCompare) = 0 then

msgbox "Equal"

else

Msgbox "Not equal"

End if

Next

 

hope this help..

 

 

Answered 03/06/2014 by: shreyas
Senior White Belt

  • This syntax worked.. Thanks a lot :)

All Answers

0

have you tried something like:

if String1 = String2 = string3 = string4 = string5 = "text" then 

....

End if


Should work fine.

 Regards,

 Marco - StockTrader

Answered 03/06/2014 by: StockTrader
Red Belt

0

you can use StrComp function in VBScript

Answered 03/07/2014 by: SilentKiller
Orange Belt

  • StrComp function works only to compare 2 strings.

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ