Jump to content

Help with division


cfdgm
 Share

Recommended Posts

Hi, I have a gui that will take input1 divide by input2 and display the number in input3.

The values input1 and input2 are saved to an INI file.

Upon opening the program the value is displayed correctly 100 / 200 = .5

My problem is that when I edit the dividend(input1) from the gui, the quotient(input3) does not update on the GUI. 

I basically want to use this as a fast calculator, where editing input 1 or input 2 will output the quotient to input3.

$drivertohole = IniRead("test.ini", "math", "drivertohole", "")
$driverdist   = IniRead("test.ini", "math", "driverdist", "")

$hInput1 = GUICtrlCreateInput($drivertohole, 160, 72, 25, 18, $ES_NUMBER)
$hInput2 = GUICtrlCreateInput($driverdist, 195, 72, 25, 18, $ES_NUMBER)
$nNumber = $drivertohole / $driverdist
$hInput3 = GUICtrlCreateInput(StringFormat("%.2f", $nNumber) & @CRLF, 230, 70, 30, 25)

Input 2 is unique because it will mostly be a constant value even though it is read from an INI.

I've been using autoit for about 2 weeks now just experimenting with things, I did several google searches and checked the help file. I am proficient in other languages and really hate asking for help because I know I'm missing something stupid.

Thanks

Also looked through some calculator source code and don't think I found what I needed, unless I missed it....

Link to comment
Share on other sites

hi. I think you mean this:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <WinAPI.au3>


Global $hGUI = GUICreate("Form1", 365, 258, 192, 124)
Global $hInput1 = GUICtrlCreateInput("10", 160, 72, 25, 18, $ES_NUMBER)
Global $hInput2 = GUICtrlCreateInput("5", 195, 72, 25, 18, $ES_NUMBER)
Global $drivertohole = GUICtrlRead($hInput1)
Global $driverdist = GUICtrlRead($hInput2)
Global $nNumber = $drivertohole / $driverdist
Global $hInput3 = GUICtrlCreateInput(StringFormat("%.2f", $nNumber) & @CRLF, 230, 70, 30, 25)
GUISetState(@SW_SHOW)


GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd


Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $hWndEdit
    $hWndFrom = $ilParam
    $iIDFrom = BitAND($iwParam, 0xFFFF)
    $iCode = BitShift($iwParam, 16)
    If $iIDFrom = $hInput1 Or $iIDFrom = $hInput2 Then
        If $iCode = $EN_CHANGE Then
            $nNumber = GUICtrlRead($hInput1) / GUICtrlRead($hInput2)
            GUICtrlSetData($hInput3,$nNumber)

        EndIf

    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Saludos

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