473,406 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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:


Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load ()
  2.  
  3. Dim ......
  4.  
  5. show form
  6.  
  7. GetSetting .....Sarttime
  8. GetSetting ....EndTime
  9. TimeX =  Format (Time, "Long Time")
  10.  
  11. Do while TimeX >= Starttime and TimeX <=Endtime
  12.   label1.Caption = "Still in Maintainence Window"
  13.   TimeFormat = DateDiff ("s" Time, Endtime)
  14.   label2.caption =  "Time remaining" & TimeFormat & "seconds"
  15.   TimeX = Time
  16.   TimeX = Format (Time, "Long Time")
  17.   DoEvents
  18. Loop
  19. End Sub
  20.  
  21.  
  22. Timer1()
  23.  
  24. Do while TimeX < Starttime and TimeX >Endtime
  25.   label1.Caption = "ONLINE"
  26.   TimeFormat = DateDiff ("s" Time, Endtime)
  27.   label2.caption =  "Time to OFFLINE" & TimeFormat & "seconds"
  28.   TimeX=Time
  29.   TimeX = Format (Time,"Long Time")
  30.   DoEvents
  31. Loop
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
Oct 30 '07 #1
2 2861
Iam Exploring the following:

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

Private Sub Form_QueryUnload()

End

End Sub
Oct 30 '07 #2
Killer42
8,435 Expert 8TB
...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.
Nov 20 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: bill | last post by:
I have 2 windows forms How can I close one of them. nothing seems to work thanks
5
by: Peter yeshew | last post by:
Is it possible to forbid closing the form through the File- Close menu ? On my form i have a command button called CmdDeleteInvoice. When this command button is visible ,i want to forbid the user...
1
by: Michel | last post by:
Yes, there is a way of forbidding a form being closed if you create a boolean variable (blnCanClose = False) in the form's Unload event. I didn't read all the responses, but I have just such a form...
5
by: RAJ | last post by:
hi plz tell me how to know "how window is going to close"... i have to right code for X button of forms... plz telll me thanks bye
7
by: Nikki | last post by:
Hi, Can anybody help me, i want to prevent windows to close my winform of ..NET application, when user presses Alt+F4
2
by: Tom_F | last post by:
To comp.databases.ms-access -- I would like to trigger an event when I close a form -- but ONLY when the data in the "RecordSource" table has been updated. I tried using the AfterUpdate event,...
11
by: Zytan | last post by:
I have created a new form from the main form. When I close the main form with the 'x' close button, its Form.FormClosed event is run, but not the dialog's. Is this normal? It is ok /...
2
by: Eric | last post by:
Hi, I have a form that requires a save button to be clicked before closing the form. I would like a msgbox to pop up when the button is not clicked before closing. Can someone show me how i...
7
by: Sin Jeong-hun | last post by:
I have a dialog form which pops up from the main window using the ShowDialog() method. this dialog has no or button, and it has quite a lot of controls on it. Now, I want to close this dialog...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.