/build/static/layout/Breadcrumb_cap_w.png

VBScript to compare more than 2 strings

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?


0 Comments   [ + ] Show comments

Answers (3)

Answer Summary:
Posted by: shreyas 10 years ago
Senior White Belt
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..

 

 


Comments:
  • This syntax worked.. Thanks a lot :) - Hariharan 10 years ago
Posted by: StockTrader 10 years ago
Red Belt
0

have you tried something like:

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

....

End if


Should work fine.

 Regards,

 Marco - StockTrader

Posted by: SilentKiller 10 years ago
Orange Belt
0

you can use StrComp function in VBScript


Comments:
  • StrComp function works only to compare 2 strings. - Hariharan 10 years ago
 
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