Perform mathematics calculation

Hi All,

I have 3 variable (All in String Format )

Var 1 = 277.12 (Format is string)
Var 2= 8.25 (Format is string)

I want to multiply var 1* var 2 = Var 3 (Result ) ( String format)


Var 3 = (Var 1 * Var 2 )/100

When I am perform the mathematical action I am facing the issue:

Assign: Input string was not in a correct format.

Kindly help Me.


convert the string to double by adding convert.todouble(eg: Convert.todouble(var1) and try.

Actually, you will want Double type value. You can use CDbl() or Convert.ToDouble(), and put that around each value. Also, always validate the value that it’s a number or this could cause future errors with bad values.

If activity: IsNumeric(Var1) And IsNumeric(Var2)
    Assign activity: Var3 = (CDbl(Var1)*CDbl(Var2))/100

Var3 is of type Double.

when you want to use Var3 as a string, just add .ToString, like Var3.ToString
EDIT: or use Var3 as a string type by adding it in the math, like ((CDbl(Var1)*CDbl(Var2))/100).ToString


1 Like

change the variable type to double by using system.double

Only thing I would add is that if you are working with monetary values, I would recommend using System.Decimal instead of System.Double because it is more precise. It’s generally only an issue for very large numbers or very small numbers, but with monetary values you generally need 100% accuracy. This can be done with CDec() or Convert.ToDecimal()

1 Like

How can i get the Standar deviation from datatable? without loops?