Perform calculation using variables

Hi,

I am trying to do a calculation where:

Purchase order quantity MINUS Previously received quantity = Remaining Amount

I get an error "option strict on disallows implicit conversations from ‘String’ to ‘Double’. What does this mean?

Regards,

Jeff

use Convert.ToInt32(yourvariable) or Convert.toDouble(yourvariable)

Hi,

Thanks for your incredibly prompt response. The problem we are having is that in the variable “Insufficient Amount” which is being used to perform the calculation the variable type is currently string. What should the variable type be here?

Regards,

Jeff

To answer your question, Int32.

You can either set it up to be straight int32, or convert it from string like @asesor-rpa has mentioned.

Hi again,

For your variables my data and other data what is the variable type for these? I want my result to have decimals.

Regards,

Jeff

If you need decimals you need to convert your string / integer to double.

Off the top of my head it would be Convert.ToDouble(yourvariable)

Hi,

Thanks for your response. I attempted to convert a string variable to a double and I got the attached error.

Regards,

Jeff

you need to use an “Assign” activity:
1.
image

see: stringtodouble.xaml (5.0 KB)

All your variables are of type String. You cannot do subtraction on strings. Best way would be to change the type of all those variables to System.Double.

If you are particular to keep the variables as String use the expression like below. Use it in an assign activity instead of using it in Default.

CStr(CDbl(POOrderQty) - CDbl(PreviouslyReceivedQty))

2019-05-30_06-01-40

Note: The above expression could cause errors, if your String variables are not valid numbers