oForm = CREATEOBJECT([Form1]) oForm.Show(1) DEFINE CLASS form1 AS form DoCreate = .T. bcancelloop = .F. Name = "form1" ADD OBJECT command1 AS commandbutton WITH ; Top = 125, ; Left = 8, ; Height = 27, ; Width = 111, ; Caption = "Start Loop", ; Name = "Command1" ADD OBJECT command2 AS commandbutton WITH ; Top = 125, ; Left = 130, ; Height = 27, ; Width = 111, ; Caption = "Cancel Loop", ; Name = "Command2" ADD OBJECT label1 AS label WITH ; AutoSize = .T., ; Caption = "Press START", ; Height = 17, ; Left = 31, ; Top = 45, ; Width = 40, ; Name = "Label1" PROCEDURE command1.Click thisform.bCancelloop = .f. lnCounter = 0 DO WHILE .t. lnCounter = lnCounter + 1 thisform.Label1.Caption = TRANSFORM(lnCounter) DOEVENTS IF thisform.bCancelloop thisform.Label1.Caption = [Loop is canceled] EXIT ENDIF ENDDO ENDPROC PROCEDURE command2.Click thisform.bCancelloop = .t. ENDPROC ENDDEFINE