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:
Expand|Select|Wrap|Line Numbers
- 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
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