russell Posted September 28, 2010 Share Posted September 28, 2010 (edited) Ok so when i try run this i get the result of 5 everytime. What have i done wronge? expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Best Team Calculator", 316, 238, 346, 262) $GroupBox1 = GUICtrlCreateGroup("", 8, 1, 297, 193) $Jersey = GUICtrlCreateInput("", 152, 24, 41, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER)) GUICtrlSetTip(-1, "Jersey Number") GUICtrlSetCursor (-1, 5) $b_rate = GUICtrlCreateInput("", 152, 48, 65, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER)) GUICtrlSetTip(-1, "Best Blocking Stat") GUICtrlSetCursor (-1, 5) $e_rate = GUICtrlCreateInput("", 152, 72, 65, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER)) GUICtrlSetTip(-1, "Best Free Throw") GUICtrlSetCursor (-1, 5) $p_rate = GUICtrlCreateInput("", 152, 96, 65, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER)) GUICtrlSetTip(-1, "Most points in a game") GUICtrlSetCursor (-1, 5) $Label1 = GUICtrlCreateLabel("Jersey #", 80, 24, 61, 17) $Label2 = GUICtrlCreateLabel("Best Blocking", 40, 48, 104, 17) $Label3 = GUICtrlCreateLabel("Best Free Throw", 48, 72, 94, 17) $Label4 = GUICtrlCreateLabel("Most Points in game", 56, 96, 87, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $Convert = GUICtrlCreateButton("Convert", 120, 203, 75, 25) GUISetState(@SW_SHOW) $Decimal = ($b_rate/ ( (1190 / 3) * $Jersey + $b_rate)) $Return = ($Decimal * '100') $b_round = Round($Return, 1) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Convert $total =(GUICtrlRead($b_round)) Switch @error Case 0 MsgBox(32, "Results", 5, $total) EndSwitch EndSwitch WEnd Edited September 29, 2010 by russell muppet hands are so soft :) Link to comment Share on other sites More sharing options...
BrewManNH Posted September 29, 2010 Share Posted September 29, 2010 you get 5 everytime because you use this line MsgBox(32, "Results", 5, $total), I THINK you want this MsgBox(32, "Results",$total, 5) if you're trying to get the messagebox to disappear in 5 seconds. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
russell Posted September 29, 2010 Author Share Posted September 29, 2010 i took the 5 out and now i get 0 everytime muppet hands are so soft :) Link to comment Share on other sites More sharing options...
BrewManNH Posted September 29, 2010 Share Posted September 29, 2010 (edited) I looked at your script a lot closer and I noticed that you do all your calculations before the entries are even put into the input lines. Your convert button does nothing more than read well...nothing. It tries to read a non-existant control because inevitably your math comes out to zero every time. Edited September 29, 2010 by BrewManNH If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
russell Posted September 29, 2010 Author Share Posted September 29, 2010 I looked at your script a lot closer and I noticed that you do all your calculations before the entries are even put into the input lines. Your convert button does nothing more than read well...nothing. It tries to read a non-existant control because inevitably your math comes out to zero every time.How can i correct this, im lost muppet hands are so soft :) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 29, 2010 Moderators Share Posted September 29, 2010 russell,You do the calculation after you press the button and you use GUICtrlRead to get the values from the inputs: While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Convert $Decimal = (GUICtrlRead($b_rate) / ((1190 / 3) * GUICtrlRead($Jersey) + GUICtrlRead($b_rate))) $Return = ($Decimal * 100) $total = Round($Return, 1) MsgBox(32, "Results", $total, 5) EndSwitch WEndHowever, I would recommend that you look carefully at the formula you use to get $Decimal - it looks like complete mathematical nonsense to me. You only use 2 of the 3 inputs, and I am not at all sure that the "Jersey Number" of the player has any place in there! You might also look at where you have the parentheses - are you doing the operations in the correct order? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
russell Posted September 29, 2010 Author Share Posted September 29, 2010 Yea the formula is really just a test to make sure the rest is working. It i a far more complex formula. You have correct the problem, thats for sure. Not i just have to study it and see how, so i actually learn how i was wrong and dont make the same mistakes later. THANK you very much guys! muppet hands are so soft :) 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