Jump to content

Recommended Posts

Posted

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
        Switch GUICtrlRead($Combo)
            Case $cn1
                MsgBox(0, "Result", $cr1)
            Case $cn2
                MsgBox(0, "Result", $cr2)
        EndSwitch
    EndIf
WEnd
Exit
Posted

#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
        
        $cr1 = GUICtrlRead($Input)*1.8+32
        
        $cr2 = (GUICtrlRead($Input)-32)/1.8
        Switch GUICtrlRead($Combo)
            Case $cn1
                MsgBox(0, "Result", $cr1)
            Case $cn2
                MsgBox(0, "Result", $cr2)
        EndSwitch
    EndIf
WEnd
Exit

Posted

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. :P

Posted

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

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

If you haven't already been welcomed:

Welcome to the AutoIt forum

Thanks :)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...