0

I really need some help trying to sort out some legacy code. We've got a MySQL server and an old VBScript front end doing some simple calculations. Briefly when calculation fees based on a commission percentage, if a certain percentage and fee is reached, then the fee is capped. Everything works until I get to fees in excess of £10000.00 and it goes wrong. I've got the following code. It all works except for the last line. Anything with a Commission of 15 returns 10000.00 and I can't figure this out.

dbLongWinAmount = FormatNumber(dbLongPPIWinAmount,2,,,0)
dbLongNetFee = (dbLongWinAmount * dbLongCommission)/100
dbLongNetFee = FormatNumber(dbLongNetFee,2,,,0)

If dbLongCommission = "30" AND dbLongNetFee >= "420.00" Then dbLongNetFee = "420.00"
If dbLongCommission = "28" AND dbLongNetFee >= "2500.00" Then dbLongNetFee = "2500.00"
If dbLongCommission = "25" AND dbLongNetFee >= "5000.00" Then dbLongNetFee = "5000.00"
If dbLongCommission = "20" AND dbLongNetFee >= "7500.00" Then dbLongNetFee = "7500.00"
If dbLongCommission = "15" AND dbLongNetFee >= "10000.00" Then dbLongNetFee = "10000.00"

Thanks for any help

  • 2
    Not SQL expert, but are you sure the comparison don't compare the strings lexicographically? – user202729 Dec 08 '21 at 12:08
  • [sql server - SQL string comparison, greater than and less than operators - Stack Overflow](https://stackoverflow.com/questions/26080187/sql-string-comparison-greater-than-and-less-than-operators) // – user202729 Dec 08 '21 at 12:09
  • Do not do this, any kind of computation/comparison should happen before applying any formatting. Formatting is purely how a value is displayed. – user692942 Dec 08 '21 at 12:10
  • @user202729 this is VBScript code in Classic ASP it's not SQL. – user692942 Dec 08 '21 at 12:11
  • [VBScript comparison operators not working? - Stack Overflow](https://stackoverflow.com/questions/15162991/vbscript-comparison-operators-not-working) (not vbscript expert either.) – user202729 Dec 08 '21 at 12:12

0 Answers0