Jump to content

calculation


Recommended Posts

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

#region GUI
Local $hGUI = 0, $iRadioCmKg = 0, $iInputHeight = 0, $iInputWeight = 0, $iButtonCalc = 0, $iInputBMI = 0

$hGUI = GUICreate("MyGUI")

GUICtrlCreateLabel("Body Mass Index", 10, 10)

$iRadioCmKg = GUICtrlCreateRadio("cm/kg", 10, 30)
GUICtrlSetState($iRadioCmKg, $GUI_CHECKED)

GUICtrlCreateRadio("in/lb", 80, 30)

GUICtrlCreateLabel("Height:", 10, 60)
$iInputHeight = GUICtrlCreateInput("", 50, 57, 80,  20, $ES_AUTOHSCROLL)

GUICtrlCreateLabel("Weight:", 10, 90)
$iInputWeight = GUICtrlCreateInput("", 50, 87, 80,  20, $ES_AUTOHSCROLL)

$iButtonCalc = GUICtrlCreateButton("Calculate", 30, 115, 80, 22)

GUICtrlCreateLabel("BMI:", 10, 150)

$iInputBMI = GUICtrlCreateInput("", 50, 147, 80,  20, $ES_AUTOHSCROLL)

GUISetState(@SW_SHOW, $hGUI)
#endregion

Local $iWeight = 0, $iHeight = 0

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $iButtonCalc
            $iWeight = Number(GUICtrlRead($iInputWeight))
            $iHeight = Number(GUICtrlRead($iInputHeight))

            If GUICtrlRead($iRadioCmKg) = $GUI_CHECKED Then
                $iRes = $iWeight / (($iHeight / 100) ^ 2)
            Else
                $iRes = ($iWeight / ($iHeight ^ 2)) * 703.06957964
            EndIf

            GUICtrlSetData($iInputBMI, Round($iRes, 2))
    EndSwitch

    Sleep(10)
WEnd

GUIDelete($hGUI)

Before asking any question, please read the helpfile.

Link to comment
Share on other sites

Case $iButtonCalc
         $iWeight = Number(GUICtrlRead($iInputWeight))
         $iHeight = Number(GUICtrlRead($iInputHeight))
         If GUICtrlRead($iRadioCmKg) = $GUI_CHECKED Then
             $iRes = $iWeight / (($iHeight / 100) ^ 2)

         Else
             $iRes = ($iWeight / ($iHeight ^ 2)) * 703.06957964
         EndIf
         $iRes=GUICtrlSetData($iInputBMI, Round($iRes, 2))
IF GUICtrlRead($iRes) <=18.5 Then
     MsgBox(0,"BMI","Underweight")
ElseIf
    
     GUICtrlRead($iRes) >=18.5 and GUICtrlRead($iRes) <=24.9 Then
     MsgBox(0,"BMI","Healthy Weight")
    
ElseIf
     GUICtrlRead($iRes) <=25 GUICtrlRead($iRes) <=29.9 Then
     
     MsgBox(0,"BMI","Overweight")
    
ElseIf
    GUICtrlRead($iRes) >=30 Then
    
     MsgBox(0,"BMI","Obese")
    
EndIf

Edited by forever0donotknowme
Link to comment
Share on other sites

Case $iButtonCalc
         $iWeight = Number(GUICtrlRead($iInputWeight))
         $iHeight = Number(GUICtrlRead($iInputHeight))
         If GUICtrlRead($iRadioCmKg) = $GUI_CHECKED Then
             $iRes = $iWeight / (($iHeight / 100) ^ 2)

         Else
             $iRes = ($iWeight / ($iHeight ^ 2)) * 703.06957964
         EndIf
         $iRes=GUICtrlSetData($iInputBMI, Round($iRes, 2))
IF GUICtrlRead($iRes) <=18.5 Then
     MsgBox(0,"BMI","Underweight")
ElseIf
    
     GUICtrlRead($iRes) >=18.5 and GUICtrlRead($iRes) <=24.9 Then
     MsgBox(0,"BMI","Healthy Weight")
    
ElseIf
     GUICtrlRead($iRes) <=25 GUICtrlRead($iRes) <=29.9 Then
    
     MsgBox(0,"BMI","Overweight")
    
ElseIf
    GUICtrlRead($iRes) >=30 Then
    
     MsgBox(0,"BMI","Obese")
    
EndIf

What is advantage form this post.
Link to comment
Share on other sites

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

#region GUI
Local $hGUI = 0, $iRadioCmKg = 0, $iInputHeight = 0, $iInputWeight = 0, $iButtonCalc = 0, $iInputBMI = 0

$hGUI = GUICreate("MyGUI")

GUICtrlCreateLabel("Body Mass Index", 10, 10)

$iRadioCmKg = GUICtrlCreateRadio("cm/kg", 10, 30)
GUICtrlSetState($iRadioCmKg, $GUI_CHECKED)

GUICtrlCreateRadio("in/lb", 80, 30)

GUICtrlCreateLabel("Height:", 10, 60)
$iInputHeight = GUICtrlCreateInput("", 50, 57, 80, 20, $ES_AUTOHSCROLL)

GUICtrlCreateLabel("Weight:", 10, 90)
$iInputWeight = GUICtrlCreateInput("", 50, 87, 80, 20, $ES_AUTOHSCROLL)

$iButtonCalc = GUICtrlCreateButton("Calculate", 30, 115, 80, 22)

GUICtrlCreateLabel("BMI:", 10, 150)

$iInputBMI = GUICtrlCreateInput("", 50, 147, 80, 20, $ES_AUTOHSCROLL)

GUISetState(@SW_SHOW, $hGUI)
#endregion

Local $iWeight = 0, $iHeight = 0

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $iButtonCalc
            $iWeight = Number(GUICtrlRead($iInputWeight))
            $iHeight = Number(GUICtrlRead($iInputHeight))

            If GUICtrlRead($iRadioCmKg) = $GUI_CHECKED Then
                $iRes = $iWeight / (($iHeight / 100) ^ 2)
            Else
                $iRes = ($iWeight / ($iHeight ^ 2)) * 703.06957964
            EndIf

            GUICtrlSetData($iInputBMI, Round($iRes, 2))
    EndSwitch

    Sleep(10)
WEnd

GUIDelete($hGUI)

Before asking any question, please read the helpfile.

excellent work.. I will read help file.

Thank you very much.

Edited by future1995man
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...