[Gambas-user] How to exit loop and close the form

Phạm Quang Dương soleilpqd at ...626...
Mon Nov 22 12:18:56 CET 2010


Thank for your answers, but the result is the same.

I let the progress run to the end but it does not automatically close.

I tried some ways:
I change "Me.Close" by:
"Me.Hide" => same result, the dialog still appears
"ProgressBar2.Visible = False" => ProgressBar2 disappears
"Quit" => when I click Cancel button or let it finish, program quits
normally.

May be I have to change my design ... ~.~ (I think about use a container
control like panel or frame on FMain + Visible attribute).

2010/11/22 Matti <math.eber at ...221...>

> You have to specify a delay to Wait. From the docs:
> "If Delay is not specified, the function processes all pending events and
> returns immediately. In that specific case, input events (keyboard and
> mouse)
> are ignored."
>
> Try it like this:
>
> Public Sub Form_Open()
>   shouldStop = False
>  Me.Show
>  doIt
> End
>
> Public Sub btnStop_Click()
>  shouldStop = True
> End
>
> Public Sub doIt()
>  Dim i As Integer, j As Integer
>
>  For i = 1 To 100
>    If shouldStop = True Then Break
>    ProgressBar1.Value = i / 100
>
>    For j = 1 To 100
>      If shouldStop = True Then Break
>      ProgressBar2.Value = j / 100
>      Print i, j        ' My job here
>      Wait 0.1
>    Next
>
>    Wait 0.1
>  Next
>
>  Me.Close()
> End
>



More information about the User mailing list