Home > Software engineering >  VBScript: Addition producing a negative number
VBScript: Addition producing a negative number

Time:02-10

I am updating an old VBScript. I was trying to add two variables together in a VBScript function I'm working on, one is a negative while the other is a positive but when the number gets sent back to the SQL table it doesn't calculate correctly. I have code that is similar to this that function correctly when you subtract

EX:-76 4 ends up being -80 instead of -72.

here is code maybe something is wrong with variable.

    strSQL = "UPDATE Parts SET On_Hand = '" 
    strSQL = strSQL & (CInt(objRS("On_Hand"))   CInt(Request.Form("QtyIssued"))) & "'"
    strSQL = strSQL & "WHERE Part_ID = '" & Request.Form("PartNum" & x) & "';"

Note: I have change Cint from Ccur and still didn't work.

On_Hand is also a float in the table.

EDIT: Added full code for clarity

  strSQL = "UPDATE Parts SET On_Hand = '" 
  strSQL = strSQL & (CInt(objRS("On_Hand"))   CInt(Request.Form("QtyIssued"))) & "'"
  strSQL = strSQL & "WHERE Part_ID = '" & Request.Form("PartNum" & x) & "';"
  Response.Write strSQL & "<br>"
  objRS.close 
  objRS.Open strSQL, objConn

Here is Response Write:

UPDATE Parts SET On_Hand = '-80'WHERE Part_ID = '15-0219';

CodePudding user response:

  •  Tags:  
  • Related