Sign in to follow this  
Followers 0
LongBowNZ

Math Problem

9 posts in this topic

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

Share this post


Link to post
Share on other sites



does it work from Fahrenheit to Celsius?

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

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

:)

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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
        
        $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

Share this post


Link to post
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. :P

Share this post


Link to post
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 this post


Link to post
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 :P

If you haven't already been welcomed:

Welcome to the AutoIt forum

Thanks :)

Share this post


Link to post
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 :P


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

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

lol, thanks anyway :)

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0