# How to get my BMI calculator to work?

Hi guys im trying to make a basic bmi calculator but I am getting these errors

1st error
When I tried to type in my height in meter (1.8m) on the input dialog, the output shows "Input Dialog: 1.8 is not a valid value for Int32 (Parameter value)

2nd error
When I use assign to save the value of Weight / Height * Height, the error were showing "BC30512: Option Strict On disallows implicit conversions from ‘Double’ to ‘Integer’. The selected value is incompatible with the property type

How can I fix this problem?

PS: All of my variable type for (IntWeight, IntHeight and IntResult are Int32)

Hi @Conning

1.8 is not an integer it was a decimal you have to change the storing of input value in a variable to double.
Change the int_Height variable type to double then you are able to store the decimals. The double datatype supports integer and decimals too.

Hope it helps!!

1 Like

Hi @Conning

If you want to give input as double as variable instead of integer type including output variable also.
`System.Double`

1 Like

Hi @Conning

Try this

`(CInt(Weight)/CInt(Height))*CInt(Height)`

Variable types must be below

I hope it helps!!

1 Like

Thank you all for your responses!

@Conning

If you got the solution please mark as solution

1 Like

Welcome @Conning

If you find the solution, please do mark as solution to close the loop

Happy Automation!!

1 Like

Hi! I have tried using your method but the BMI I got was from the weight(67)

Is there anything else that I need to change?

Thanks for helping!

@Conning

Ex:60/5.6 * 5.6 so height will be cancel the result will be 60

I think your formula will be (weight/(height*Weight))

1 Like

@Conning

When you use the below formula

(Weight/Height)*Height

You will get the weight only so please check the formula

Use the below formula instead of that

Weight/(Height*Height)

mention the height in metres

Regards

1 Like

You are giving the wrong syntex below
give like this

``````The formula for BMI is weight/height square you have to encapsulate height*height in curve brackets
Cint(Weight)/(Cint(Height)*Cint(Height))
``````

1 Like

Hi @Conning

Input Dialog (Title: “Enter Height in Meters”, Output: strHeight)
IntHeight = Convert.ToInt32(Double.Parse(strHeight))
DoubleResult = Weight / (IntHeight * IntHeight)
Input Dialog (Title: “Enter Height in Meters”, Output: strHeight)
Assign - IntHeight = Convert.ToInt32(Double.Parse(strHeight))

Input Dialog (Title: “Enter Weight in Kilograms”, Output: strWeight)
Assign - IntWeight = Convert.ToInt32(Double.Parse(strWeight))

Assign - DoubleResult = IntWeight / (IntHeight * IntHeight)

Log Message (Message: "Your BMI is " + DoubleResult.ToString())

Hope it helps!!

1 Like

@Conning

Try this

(CInt(Weight))/(CInt(Height)*CInt(Height))

1 Like

@Conning

If you find the solution mark as solution

@Conning If you find the solution for your query do mark as solution to close the loop

Happy Automation!!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.