nicksmsfn Posted June 29, 2004 Share Posted June 29, 2004 In the following VBScript code I'm trying to compare two numbers and pass the operator from the command line. I substitute the words "greater", "less" and "equal" instead of the symbols to not upset the shell. However the If..Then statement doesn't like me using the variable for the operator. Any ideas. Thanks for the help.Set objShell = WScript.CreateObject("WScript.Shell")Set colArgs = WScript.Argumentsstr1stnumber = colArgs.Item(0)str2ndnumber = colArgs.Item(1)strOperator = colArgs.Item(2)If strOperator = "less" Then strOperator = "<"ElseIf strOperator = "greater" Then strOperator = ">"ElseIf strOperator = "equal" Then strOperator = "="End IfIf str1stnumber strOperator str2ndnumber Then wscript.echo "it works"End If Link to comment Share on other sites More sharing options...
maxXPsoft Posted July 2, 2004 Share Posted July 2, 2004 I think this is what you're asking.http://www.ronshardwebapps.com/tips/septtu...loperators2.aspFirst Hit in GoogleBut it crashes on me hereIf str1stnumber strOperator str2ndnumber ThenExpected 'Then'I think you need somethying in there or I just don't see what you're trying to do. Link to comment Share on other sites More sharing options...
/\/\o\/\/ Posted July 2, 2004 Share Posted July 2, 2004 maybe this is an option ?gr /\/\o\/\/If strOperator = "greater" AND str1stnumber < str2ndnumber Then wscript.echo "it works greater"ElseIf strOperator = "less" AND str1stnumber > str2ndnumber Then wscript.echo "it works less"ElseIf strOperator = "equal" AND str1stnumber = str2ndnumber Then wscript.echo "it works equal"endif Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now