Jump to content

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
        Switch GUICtrlRead($Combo)
            Case $cn1
                MsgBox(0, "Result", $cr1)
            Case $cn2
                MsgBox(0, "Result", $cr2)
        EndSwitch
    EndIf
WEnd
Exit
Link to comment
Share on other sites

  • Developers

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

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

:)

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...