Convert Fahrenheit to Celcius?

Noel

Member
Licensed User
Longtime User
I am trying to convet Fahrenheit to Celcius.

The formula to do so is: C = (F - 32) / 1.8 (where F is the Fahrenheit value)

For some reason does
Code: Copy
Celcius = (30 - 32) / 1.8
give me -1, but when doing the calculation on a calculator is shows -1.11111

I need the -1.11111 value. How can I get this done in "basic"?

Same with
Code: Copy
Celcius = (22 - 32) / 1.8
In basic it returns -5
When doing the maths on a calculator it gives me -5.55....
 
Last edited:
You need to declare the variables as double:
Code: Copy
Dim F As Double=30
Dim C As Double
C=(F-32)/1.8
Msgbox (C,"")  'returns -1.11111
 
Upvote 0
Back
Top