Jump to content

(SOLVED)ProgressBar problem with Nested For


Recommended Posts

I was having some problems with Progressbar with  nested "FOR" Loop but I was using it unnecessarily so I end up with only one "FOR" Loop.

Here I'm sharing with you two ways of solve the progressbar problem, this is not for advanced users, this is for reference and newbies like me.

And about the progressbar using GUICtrlSetData() with one FOR Loop and variable cicles(for example cicles base of elements on Array with variable size) you can do it as fallow:
Note: Does not matter if the Array size is 50 or 5000 the progressbar will work properly.

$progress = GUICtrlCreateProgress()

Local $count = UBound($Array)
Local $imove = ((1 / $count) * 100) ; One is because you will SetData to Progress each 1 cicle.
Local $itemp = 0

For $i = 0 To UBound($Array) - 1

    ; Your Code could be here

    $itemp += $imove
    GUICtrlSetData($progress, $itemp)


    ; Or your code could be here.

Next

 

Another way to do it and I think is more elegant or fancy is like this:

$progress = GUICtrlCreateProgress()

Local $itemp = 0
Local $count = 0
Local $intcount = Floor(Ubound($Array)/100)

For $i = 0 To UBound($Array) - 1

    ; Your Code could be here

    If Mod($i, $intcount) == 0 Then
        $count = $count+1
        GUICtrlSetData($progress, $count)
    EndIf

    ; Or your code could be here.


Next


Kind Regards
Alien.
 

Edited by alien4u
Problem Solved and Show some examples, Fixed Typo
Link to comment
Share on other sites

  • 3 weeks later...

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

×
×
  • Create New...