Jump to content

[HELP] Perform arithmetic on upvalue, wut?


..:D&G:..

Recommended Posts

I keep getting this error when I try to get the text from a grid list I get this error: Attempt to perform arithmetic on upvalue "bankBalance" (a nil value)

if (not wrong) then 
          if (money ~= nil) and (tonumber(amount) <= money) then 
              if (tonumber(amount) > 0) then 
               local bankBalance = guiGridListGetItemText(accountList, selectedRow, 3) 
              bankBalance = "$".. tostring( bankBalance + amount ) 

Any ideas guys? Thanks.

Link to comment
if (not wrong) then 
          if (money ~= nil) and (tonumber(amount) <= money) then 
              if (tonumber(amount) > 0) then 
               local bankBalance = guiGridListGetItemText(accountList, selectedRow, 3) 
              bankBalance = "$".. tostring( bankBalance + amount ) 

bankBalance is a string right? you have to first convert it to a number token, then you have to do the respective arithmetic operations. you cant do arithmetic operations with a string. So, try using tonumber( ) and try to convert the bankBalance to a number first..

If it still doesnt work then pls tell.

Btw you can check if its a number.. using the same tonumber ()

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...