Jump to content

Why cant I get it to display right?


mrbloody369
 Share

Recommended Posts

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"

Link to comment
Share on other sites

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

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

I get that feeling a lot too!

Not that it really matters, but I'm not sure if it's conventional to use only numbers as variables... There's usually at least some string in the variable name...

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
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...