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

Phạm Quang Dương soleilpqd at ...626...
Sun Nov 21 15:45:01 CET 2010


Hi,

I want create a dialog form which showes the current progress and let user
stop the operation and close this dialog by clicking a Cancel button
On form1 I have 2 progress bars and 1 button:

Private shouldStop as Boolean

Private Sub Form_Open()
shouldStop = False
Me.Show()
doIt() 'Main loop of the operation
End

Private Sub Button1_Click()
shouldStop = True
Me.Close()
End

Private Sub doIt()
Dim i As Interger, j As Interger
i = 1
Repeat
j = 1
Repeat
Wait 'Let user click Cancel button
' My job here
ProgressBar2.Value = j / 100
j += 1
Until shouldStop Or j = 100
ProgressBar1.Value = i / 100
i += 1
ProgressBar2.Reset()
Until shouldStop Or i = 100
Me.Close()
End

On FMain I call:

form1.ShowDialog()

In real-time when I click Cancel button first time, the operation (progress
bar) stoppes but the form does not close until I click Cancel button the
second time.

I think that my code is bad but I can not find the better solution. Please
help! Thank you.



More information about the User mailing list