Math Problem

Recommended Posts

When I convert 200 Celsius to Fahrenheit it displays 39.2 but 200°C is 392°F.

I don't know what is wrong since I'm 99% sure I've got the maths right.

```#NoTrayIcon
#include <GUIConstants.au3>
#include <Math.au3>

GUICreate("Conversion", 480, 50, -1, -1,\$WS_POPUP)
GUISetBkColor("0xAAAAFF")
GUISetState()

\$Group = GUICtrlCreateGroup("Conversion", 0, 0, 480, 50)
\$Input = GUICtrlCreateInput("Enter Number", 10, 20, 90, 20)
#region Conversion Data
\$cn1 = "Celsius to Fahrenheit"
\$cr1 = \$Input*1.8+32
\$cn2 = "Fahrenheit to Celsius"
\$cr2 = (\$Input-32)/1.8
#endregion Conversion Data
\$Combo = GUICtrlCreateCombo("", 110, 20, 300, 21)
GUICtrlSetData(\$Combo, \$cn1 & "|" & \$cn2)
\$Button = GUICtrlCreateButton("Convert", 420, 20, 50, 20)
\$Exit = GUICtrlCreateButton("X", 465, 1, 14, 14)

While 1
\$msg = GUIGetMsg()
If \$msg = \$Exit Then
ExitLoop
EndIf
If \$msg = \$Button Then
Case \$cn1
MsgBox(0, "Result", \$cr1)
Case \$cn2
MsgBox(0, "Result", \$cr2)
EndSwitch
EndIf
WEnd
Exit```

Share on other sites

does it work from Fahrenheit to Celsius?

Share on other sites

Use GuiCtrlRead(\$input) to retrieve the entered value ...

... and this needs to be done when the button is clicked ...

Edited by JdeB

Live for the present,
Dream of the future,
Learn from the past.

Share on other sites

```#NoTrayIcon
#include <GUIConstants.au3>
#include <Math.au3>

GUICreate("Conversion", 480, 50, -1, -1,\$WS_POPUP)
GUISetBkColor("0xAAAAFF")
GUISetState()

\$Group = GUICtrlCreateGroup("Conversion", 0, 0, 480, 50)
\$Input = GUICtrlCreateInput("Enter Number", 10, 20, 90, 20)
#region Conversion Data
\$cn1 = "Celsius to Fahrenheit"
\$cn2 = "Fahrenheit to Celsius"
#endregion Conversion Data
\$Combo = GUICtrlCreateCombo("", 110, 20, 300, 21)
GUICtrlSetData(\$Combo, \$cn1 & "|" & \$cn2)
\$Button = GUICtrlCreateButton("Convert", 420, 20, 50, 20)
\$Exit = GUICtrlCreateButton("X", 465, 1, 14, 14)

While 1
\$msg = GUIGetMsg()
If \$msg = \$Exit Then
ExitLoop
EndIf
If \$msg = \$Button Then

Case \$cn1
MsgBox(0, "Result", \$cr1)
Case \$cn2
MsgBox(0, "Result", \$cr2)
EndSwitch
EndIf
WEnd
Exit```

Share on other sites

Thanks JdeB for trying to explain it to me.

Thanks danwilli for the code cause I couldn't do what JdeB said, I was nearly there but would have taken a few hours to figure it out.

Share on other sites

No prob... JdeB is the man. He knows a LOT.

If you haven't already been welcomed:

Welcome to the AutoIt forum

Share on other sites

No prob... JdeB is the man. He knows a LOT.

1 thing he doesn't know is how noob I am

If you haven't already been welcomed:

Welcome to the AutoIt forum

Thanks

Share on other sites

1 thing he doesn't know is how noob I am

just want to give you a chance to sort it out first yourself ... or maybe I am just lazy

Live for the present,
Dream of the future,
Learn from the past.

Share on other sites

just want to give you a chance to sort it out first yourself ... or maybe I am just lazy

lol, thanks anyway

Create an account

Register a new account