Mehomic Posted November 15, 2013 Share Posted November 15, 2013 I have a problem in displaying the output to the gui from the following script. Can someone cast their beady eyes over it and suggest a suitable way around it. Also, is there a way to 'reset' the script without re-starting it? Enabling the re-use. Any ideas for improvement would be greatfully received. TIA expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_UseX64=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs A GUI to display the VAT content FileName: VATcalc.au3 Version: 1.0.0 Author: Code Mehomic Date: 20-May 2012 Autoit Version: 3.3.6.1 Scite: 2.27 #ce #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <Constants.au3> #include <Math.au3> Opt('MustDeclareVars', 1) Global $nMsg, $Input_VatRate, $Calc_IncVat, $VatRate, $NetRate, $Vat1, $Gross1, $Vat2, $Gross2, $Convert1 GUICreate("VAT Calculator by Mehomic 2012", 400, 400, -1, -1) ;>> will create a dialog box that when displayed is centered ;>> INPUT THE VAT RATE AS A PERCENTAGE $Input_VatRate = GUICtrlCreateGroup(" Input Vat Rate ", 8, 16, 384, 55) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlCreateLabel("Vat Rate:", 16, 42, 45, 17) GUICtrlSetTip(-1, "Input the VAT rate without percentage sign") $VatRate = GUICtrlCreateInput("", 70, 37, 40, 21) GUICtrlSetColor(-1, 0x000000) GUICtrlSetBkColor(-1, 0xFFFFFF) ;>> CALCULATE VAT INCLUSIVE $Calc_IncVat = GUICtrlCreateGroup(" Calculate VAT Inclusive ", 8, 75, 384, 55) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlCreateLabel("Net Rate:", 16, 101, 50, 17) GUICtrlSetTip(-1, "Input the Net rate") $NetRate = GUICtrlCreateInput("", 70, 96, 65, 21) GUICtrlSetColor(-1, 0x000000) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlCreateLabel("Vat:", 154, 101, 45, 17) $Vat1 = GUICtrlCreateInput("0.00", 180, 96, 65, 21) GUICtrlSetColor(-1, 0x000000) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlCreateLabel("Gross:", 250, 101, 45, 17) $Gross1 = GUICtrlCreateInput("0.00", 285, 96, 65, 21) GUICtrlSetColor(-1, 0x000000) GUICtrlSetBkColor(-1, 0xFFFFFF) $convert1 = GUICtrlCreateButton("Convert", 50, 257, 75, 25) GUISetState(@SW_SHOW) ;>> will display an empty dialog box ;>> Run the GUI until the dialog is closed While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Convert1 $VatRate = GUICtrlRead($VatRate, 1) ;>> read the VatRate input by user $NetRate = GUICtrlRead($NetRate, 1) ;>> read the NetRate input by user ;>> CALCULATE THE FIGURES $Vat1 = $NetRate / 100 * $VatRate $Gross1 = $NetRate + $Vat1 $Vat2 = Round($Vat1, 2) ;>> round output vat amount to two decimal figures $Gross2 = Round($Gross1, 2) ;>> round output gross amount to two decimal figures ;>> NOW DISPLAY THE OUTPUT MsgBox(0, "CALCULATED VAT RATE", "Net Rate: £" & $NetRate & @CRLF & "Vat: £" & $Vat2 & @CRLF & "Gross Paid: £" & $Gross2 & @CRLF) EndSwitch WEnd GUIDelete() ; ; ----------------------------------------------- end of file -------------------------------------------------------------------------------- ; Code Mehomic Link to comment Share on other sites More sharing options...
kylomas Posted November 16, 2013 Share Posted November 16, 2013 Mehomic, Like this...? expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_UseX64=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs A GUI to display the VAT content FileName: VATcalc.au3 Version: 1.0.0 Author: Code Mehomic Date: 20-May 2012 Autoit Version: 3.3.6.1 Scite: 2.27 #ce #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <Constants.au3> #include <Math.au3> #include <StaticConstants.au3> Opt('MustDeclareVars', 1) Global $nMsg, $Input_VatRate, $Calc_IncVat, $VatRate, $NetRate, $Vat1, $Gross1, $Vat2, $Gross2, $Convert1 GUICreate("VAT Calculator by Mehomic 2012", 400, 400, -1, -1) ;>> will create a dialog box that when displayed is centered ;>> INPUT THE VAT RATE AS A PERCENTAGE $Input_VatRate = GUICtrlCreateGroup(" Input Vat Rate ", 8, 16, 384, 55) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlCreateLabel("Vat Rate:", 16, 42, 45, 17) GUICtrlSetTip(-1, "Input the VAT rate without percentage sign") $VatRate = GUICtrlCreateInput("", 70, 37, 40, 21) GUICtrlSetColor(-1, 0x000000) GUICtrlSetBkColor(-1, 0xFFFFFF) ;>> CALCULATE VAT INCLUSIVE $Calc_IncVat = GUICtrlCreateGroup(" Calculate VAT Inclusive ", 8, 75, 384, 55) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlCreateLabel("Net Rate:", 16, 101, 50, 17) GUICtrlSetTip(-1, "Input the Net rate") $NetRate = GUICtrlCreateInput("", 70, 96, 65, 21) GUICtrlSetColor(-1, 0x000000) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlCreateLabel("Vat:", 154, 101, 45, 17) $Vat1 = GUICtrlCreatelabel("", 180, 96, 65, 21, bitor($SS_SUNKEN,$SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetColor(-1, 0x000000) guictrlsetfont(-1,10,800) GUICtrlCreateLabel("Gross:", 250, 101, 45, 17) $Gross1 = GUICtrlCreatelabel("", 285, 96, 65, 21, bitor($SS_SUNKEN,$SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetColor(-1, 0x000000) guictrlsetfont(-1,10,800) $convert1 = GUICtrlCreateButton("Convert", 50, 257, 75, 25) GUISetState(@SW_SHOW) ;>> will display an empty dialog box ;>> Run the GUI until the dialog is closed While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $convert1 $VatRate = GUICtrlRead($VatRate, 1) ;>> read the VatRate input by user $NetRate = GUICtrlRead($NetRate, 1) ;>> read the NetRate input by user ;>> CALCULATE THE FIGURES guictrlsetdata($Vat1, round( ($NetRate / 100) * $VatRate,2)) ; <<< guictrlsetdata($Gross1, round($NetRate + $Vat1,2)) EndSwitch WEnd GUIDelete() ; ; ----------------------------------------------- end of file -------------------------------------------------------------------------------- ; kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Solution Mehomic Posted November 18, 2013 Author Solution Share Posted November 18, 2013 kylomas: Thanks for your reply and, casting your expert eye over my script. I was unaware of the GUICtrlSetData() and this has fixed it, also the #include <StaticConstants.au3> Again many thanks for your input and help. Kind regards Code Mehomic Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now