Hi All, I am a new user to ASP and would like to add a to an accumalted value.

The value stored in QTYALLOC can be a 1 or a 2 but currently the code will only add increment by 1, but what I am trying to do is increment by the value of QTYALLOC. I had placed order in the increment counter (StockAllocate + 1) like so (StockAllocate + 1) but this did not seem to work. My syntax mak not be correct.

What I have tried is not working. Any assistance would be appriciated.

if rowStock("QTYALLOC") <> "0" then
    ' allocated
    order= rowStock("QTYALLOC")
    StockAllocate = (StockAllocate + 1)
end if

Thanks in advance

David

Recommended Answers

All 4 Replies

I had placed order in the increment counter (StockAllocate + 1) like so (StockAllocate + 1) but this did not seem to work.

Where? I don't see that.

Maybe this is what you want to do?

 StockAllocate = (Order + 1)

Hi JorgeM, thanks for your reply.

QTYALLOC is holding a values of 0, 1 or 2 rather than add 1 to StockAllocate = (StockAllocate + 1)

I want to add the value 2 to (StockAllocate + QTYALLOC) so I put the value of QTYALLOC into a variable called order ie order= rowStock("QTYALLOC") and then add the value to (StockAllocate + order) so when the value is a 2 it will increment (StockAllocate + 2) this didn't work

below is how I think the process should work and how I have written it, but does not seem to work.

if rowStock("QTYALLOC") <> "0" then
    ' allocated
    order= rowStock("QTYALLOC")
    StockAllocate = (StockAllocate + order)
end if

I hope that helps

Fhanks in advance

David

Ok, lets start over...

What is rowStock("QTYALLOC")? is this a fuction you are calling or soemthing?

Whatever it is, it is apparent that you are trying to assign that value to the variable order. Are you sure that order is actually storing an integer and not a string?

If you are not sure if its of type integer, you could do this...

order = CInt(rowStock("QTYALLOC"))

Now, you say "I want to add the value 2 to (StockAllocate + QTYALLOC)", then this should work, assuming that StockAllocate is storing a number as well.

StockAllocate = StockAllocate + order + 2

This takes the current value in StockAllocate, adds the value in order and then adds 2 to that value. This is what you described above.

If these variables are storing strings rather than integers, then when you do something like variabeA + variableB, the result is say...

varA = "John"
varB = "Smith"
varC = "2"
varD = "5"

varA + varB = "JohnSmith"
varC + varD = "25"

When you add strings, you concat them together.

I hope this helps...

Thanks for your help JorgeM, converting the value from a string to an Integer value did the trick.

Thanks

David

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.