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"


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


Community Chosen Answer



to compare multiple string :-

take an array



for each x in b

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

msgbox "Equal"


Msgbox "Not equal"

End if



hope this help..



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

  • This syntax worked.. Thanks a lot :)

All Answers


have you tried something like:

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


End if

Should work fine.


 Marco - StockTrader

Answered 03/06/2014 by: StockTrader
Red Belt


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


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