VB6 Form Not Closing, relaunching when press close

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • benitez
    New Member
    • Oct 2007
    • 4

    VB6 Form Not Closing, relaunching when press close

    Hi All,

    I am new here and new to VB6, My Do Loop and DoEvents seem to cause me problem hence am kindly asking for help. Iam using VB6

    I have code in Form_load() which gathers registry values using getsettings (Starttime and EndTime) these settings are then used in the Do Loop as follows:


    [CODE=vb]Private Sub Form_Load ()

    Dim ......

    show form

    GetSetting .....Sarttime
    GetSetting ....EndTime
    TimeX = Format (Time, "Long Time")

    Do while TimeX >= Starttime and TimeX <=Endtime
    label1.Caption = "Still in Maintainence Window"
    TimeFormat = DateDiff ("s" Time, Endtime)
    label2.caption = "Time remaining" & TimeFormat & "seconds"
    TimeX = Time
    TimeX = Format (Time, "Long Time")
    DoEvents
    Loop
    End Sub


    Timer1()

    Do while TimeX < Starttime and TimeX >Endtime
    label1.Caption = "ONLINE"
    TimeFormat = DateDiff ("s" Time, Endtime)
    label2.caption = "Time to OFFLINE" & TimeFormat & "seconds"
    TimeX=Time
    TimeX = Format (Time,"Long Time")
    DoEvents
    Loop[/CODE]

    The problem is when I click close button X on the form (top right-hand corner), it doesn't close, it relaunches the form and does everything again.
    I want to force the form to close when X is pressed. The problem seems to be the first DO Loop


    Also in my Error handler the behaviour is the same: i.e.

    Form Load()

    Dim

    On ErrorHandler GoTo ErrorHandler





    ErrorHandler:
    Dim

    Show Form

    Label.caption = "Error Launching Application"


    Sleep 10
    DoEvents

    Resume



    End Sub

    when you close the application when there is an error the window relaunches again ang cannot be closed

    Please help in anyway you can.

    Thanking you in Advance

    Benitez
    Last edited by Killer42; Nov 20 '07, 02:08 AM. Reason: Added CODE=vb tag
  • benitez
    New Member
    • Oct 2007
    • 4

    #2
    Iam Exploring the following:

    In Form Query Unload() or Form Unload add the END command i.e.

    Private Sub Form_QueryUnloa d()

    End

    End Sub

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      Originally posted by benitez
      ...The problem is when I click close button X on the form (top right-hand corner), it doesn't close, it relaunches the form and does everything again. I want to force the form to close when X is pressed. The problem seems to be the first DO Loop
      Using the END statement is one possibility. You could also create a flag at the form (or global) level, set your Do loop(s) to finish when it is set, and set it when the user clicks Close.

      Comment

      Working...