Rex Posted December 31, 2009 Posted December 31, 2009 (edited) Hi Happy NewYear I have a math problem, i dont know how to calc the % of XX entrys I'm using this code $Read = GUICtrlRead($Company_Combo) If Not @error Then ; Check if there is a read error, if so we don't do anything else we compair data from addressbook and combo If $Key > 0 Then GUISetState(@SW_HIDE, $booking) ProgressOn("Opdater Database", "Opdater databasen Vent venligst...") IniDelete(@ScriptDir & "\Address.Adr", "Companys", $Key) IniDelete(@ScriptDir & "\Address.Adr", _StringToHex($Read)) Button_ClearClick() ; Clears inputs and combos Local $aList ; Get List $aList = _GUICtrlComboBox_GetListArray($Company_Combo) $Persent = ($aList[0] / 100) For $x = 1 To $aList[0] IniWriteSection(@ScriptDir & "\Address.Adr", "COUNT", "Last=" & $aList[0]) IniWrite(@ScriptDir & "\Address.Adr", "COMPANY", $x, _StringToHex($aList[$x])) $Persent = $Persent + 1 ProgressSet($Persent, $Persent & " % nået) Next IniDelete(@ScriptDir & "\Address.Adr", "Companys") IniRenameSection(@ScriptDir & "\Address.Adr", "COMPANY", "COMPANYS") ProgressSet(100) ProgressOff() GUISetState(@SW_SHOW) EndIf EndIf And current testing it up against a list containing 592 entry's, but for som reason i don't get my % by /100 - and i realy don't know how to do it els where, i think i forgot to be to school the day we learned that type of math Can any one help me calculate i Cheers /Rex Edited December 31, 2009 by Rex
cageman Posted December 31, 2009 Posted December 31, 2009 (edited) I think you mean something like below? if you round $Persent to zero decimals it would give the rounded percentage, which you probably want. Good luck. $Read = GUICtrlRead($Company_Combo) If Not @error Then ; Check if there is a read error, if so we don't do anything else we compair data from addressbook and combo If $Key > 0 Then GUISetState(@SW_HIDE, $booking) ProgressOn("Opdater Database", "Opdater databasen Vent venligst...") IniDelete(@ScriptDir & "\Address.Adr", "Companys", $Key) IniDelete(@ScriptDir & "\Address.Adr", _StringToHex($Read)) Button_ClearClick() ; Clears inputs and combos Local $aList ; Get List $aList = _GUICtrlComboBox_GetListArray($Company_Combo) For $x = 1 To $aList[0] IniWriteSection(@ScriptDir & "\Address.Adr", "COUNT", "Last=" & $aList[0]) IniWrite(@ScriptDir & "\Address.Adr", "COMPANY", $x, _StringToHex($aList[$x])) $Count = $Count + 1 $Persent=($Count/$aList[0])*100 ProgressSet($Persent, $Persent & " % nået) Next IniDelete(@ScriptDir & "\Address.Adr", "Companys") IniRenameSection(@ScriptDir & "\Address.Adr", "COMPANY", "COMPANYS") ProgressSet(100) ProgressOff() GUISetState(@SW_SHOW) EndIf EndIf edit for the future: you can calculate a percentage by getting the fraction of things done / total amount. Then multiply that by 100. Edited December 31, 2009 by cageman
Rex Posted December 31, 2009 Author Posted December 31, 2009 I think you mean something like below? if you round $Persent to zero decimals it would give the rounded percentage, which you probably want. Good luck. $Read = GUICtrlRead($Company_Combo) If Not @error Then ; Check if there is a read error, if so we don't do anything else we compair data from addressbook and combo If $Key > 0 Then GUISetState(@SW_HIDE, $booking) ProgressOn("Opdater Database", "Opdater databasen Vent venligst...") IniDelete(@ScriptDir & "\Address.Adr", "Companys", $Key) IniDelete(@ScriptDir & "\Address.Adr", _StringToHex($Read)) Button_ClearClick() ; Clears inputs and combos Local $aList ; Get List $aList = _GUICtrlComboBox_GetListArray($Company_Combo) For $x = 1 To $aList[0] IniWriteSection(@ScriptDir & "\Address.Adr", "COUNT", "Last=" & $aList[0]) IniWrite(@ScriptDir & "\Address.Adr", "COMPANY", $x, _StringToHex($aList[$x])) $Count = $Count + 1 $Persent=($Count/$aList[0])*100 ProgressSet($Persent, $Persent & " % nået") Next IniDelete(@ScriptDir & "\Address.Adr", "Companys") IniRenameSection(@ScriptDir & "\Address.Adr", "COMPANY", "COMPANYS") ProgressSet(100) ProgressOff() GUISetState(@SW_SHOW) EndIf EndIf Cool That i could newer have done by my self. And with ProgressSet($Persent, Round($Persent) & " % nået) It looks like pro. Thx Cheers /Rex
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