Jump to content

Recommended Posts

Posted

I'm trying to get auto it to do the math correct and desplay the answer for a long equashion(s) and it's fighting me <.< ..

Here is an example: to better under stand me

The user enters the following

Input 1 = 50

Input 2 = 50

Input 3 = 50

Input 4 = 1

$total = (5 * $4) + ($Input1 * 0.2) + ($Input2 * 0.1) + ($Input3 * 0.1) + 50

If I input the info in exel I get the answer "85" witch is correct

=SUM((5*3)+(50*0.2)+(50*0.1)+(50*0.1)+50)

What am I doing wrong that autoit doesn't want to do the math correct? I have looked though the help file and search the forum. I'm clue less

Tride 3 difrent ways to script it and none gave the corect anwser .

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("AForm1", 379, 241, 225, 111)
$Label1 = GUICtrlCreateLabel("100", 216, 48, 125, 84)
GUICtrlSetFont(-1, 50, 400, 0, "MS Sans Serif")
$EXIT = GUICtrlCreateButton("EXIT", 248, 192, 75, 25, 0)
$CALC = GUICtrlCreateButton("CALC", 168, 192, 75, 25, 0)
$Input1 = GUICtrlCreateInput("Input 1 (1~999)", 32, 32, 121, 21)
$Input2 = GUICtrlCreateInput("Input 2 (1~999)", 32, 64, 121, 21)
$Input3 = GUICtrlCreateInput("Input 3 (1~999)", 32, 96, 121, 21)
$Input4 = GUICtrlCreateInput("Input 4 (1~3)", 32, 128, 121, 21)
$Label2 = GUICtrlCreateLabel("Anwser", 232, 8, 92, 36)
GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    Switch GUIGetMsg()
        Case $CALC
            $1 = GUICtrlRead($Input1)
            $2 = GUICtrlRead($Input2)
            $3 = GUICtrlRead($Input3)
            $4 = GUICtrlRead($Input4)

            If $1 = 0  Or $2 = 0 Or $3 = 0 Or $4 = 0 Then
                MsgBox(1,"ERROR","Please end an number from 1~999 in all input boxes")
            Else
                
                $t = _totalNum()
                GUICtrlSetData($Label1,$t)
            EndIf

        Case $GUI_EVENT_CLOSE, $EXIT
            Exit

    EndSwitch
WEnd

Func _totalNum()
    $total = (5 * $4) + ($1 * 0.2) + ($2 * 0.1) + (3 * 0.1) + 50
    Return $total
EndFunc

Any idea's?

Mr B

Favorite Quotes"If you apply your mind you can create any thing you can dream of" "Any thing can get done by simply click of a button"

Posted (edited)

$total = (5 * $4) + ($1 * 0.2) + ($2 * 0.1) + (3 * 0.1) + 50

$total = (5 * $4) + ($1 * 0.2) + ($2 * 0.1) + ($3 * 0.1) + 50 ... is correct

8)

.... too slow

Edited by Valuater

NEWHeader1.png

Posted

I feel so.. <.< :) :)

Aslo realized I typed 3 in exel instead 1 ... I'm ashamed..

Favorite Quotes"If you apply your mind you can create any thing you can dream of" "Any thing can get done by simply click of a button"

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