[Gambas-user] Me.Close not working as expected

Gianluigi bagonergi at gmail.com
Thu Jul 1 19:13:24 CEST 2021


Il giorno gio 1 lug 2021 alle ore 19:05 bb <adamnt42 at gmail.com> ha scritto:

> On Thu, 2021-07-01 at 17:37 +0100, Charlie Ogier wrote:
> > Hi,
> >
> > Can you try this code and see if you experience my problem. The
> > program
> > should end on clicking the button, but it doesn't close until the end
> > of
> > the 'Sub'.
> >
> > Thanks,
> >
> > Charlie
> >
> > ***Code***
> > Button1 As Button
> >
> > Public Sub Form_Open()
> >
> >    With Me
> >      .Height = 400
> >      .Width = 500
> >      .Padding = 5
> >      .Center
> >    End With
> >
> >    With Button1 = New Button(Me) As "Button1"
> >      .W = 100
> >      .H = 28
> >      .X = 10
> >      .Y = 10
> >      .Text = "&Click me!"
> >    End With
> >
> > End
> >
> > Public Sub Button1_Click()
> >
> >    Dim iLoop As Integer
> >
> >    Me.Close '' Shouldn't the program stop here?
> >
> >    For iLoop = 0 To 1000
> >      Print Str(iLoop) & " Hello"
> >    Next
> >
> > End
> >
> > ***End code***
> >
> > ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
> You are just closing the form, not the executing instance of the
> project.
> If you really want to "kill" the execution, then use Quit.
>
>
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>

i think that you should add this, the use of quit in graphics programs is
not recommended:

Private $bStop As Boolean

  Public Sub Button1_Click()

  Dim iLoop As Integer

  Me.Close '' Shouldn't the program stop here?
  $bStop = True

  For iLoop = 0 To 1000
    Print Str(iLoop) & " Hello"
    If $bStop Then Break
  Next

End

Regards

Gianluigi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20210701/a5f8cf63/attachment.htm>


More information about the User mailing list