|
-
Aug 3rd, 2006, 06:42 PM
#1
Thread Starter
Lively Member
[RESOLVED] form wont unload?
hi guys, well what it is my form wont proply unload when useing winsock.
when i open the form and close it straight away, it unload fine but when i connect to my server useing winsock, i unload the form but i have to press Ctrl,Alt,Delete and end the task? does anyone know how to prevent me haveing to do this everytime? thanks
-
Aug 3rd, 2006, 07:03 PM
#2
Addicted Member
Re: form wont unload?
 Originally Posted by Lazer
hi guys, well what it is my form wont proply unload when useing winsock.
when i open the form and close it straight away, it unload fine but when i connect to my server useing winsock, i unload the form but i have to press Ctrl,Alt,Delete and end the task? does anyone know how to prevent me haveing to do this everytime? thanks
VB Code:
Private Sub Form_Unload(Cancel As Integer)
If Winsock1.State <> sckClosed Then Winsock1.Close 'close if any connection is trying to be made
Unload Me 'unload the form
End 'terminate the program
End Sub
-
Aug 3rd, 2006, 07:15 PM
#3
Re: form wont unload?
 Originally Posted by XRsTX
VB Code:
Private Sub Form_Unload(Cancel As Integer)
If Winsock1.State <> sckClosed Then Winsock1.Close 'close if any connection is trying to be made
Unload Me 'unload the form
End 'terminate the program
End Sub
The form is already unloading so there is no need to call Unload Me again.
And never use End. Forget it exists. All objects / connections / etc. should be unloaded / destroyed / closed / etc. in your Form_Unload event.
-
Aug 3rd, 2006, 08:00 PM
#4
Thread Starter
Lively Member
Re: form wont unload?
VB Code:
Private Sub form_unload(Cancel As Integer)
If connection.State <> sckClosed Then connection.Close
End Sub
it still shows in the windows task manager. i realy cant understnad why its doing this
-
Aug 3rd, 2006, 09:54 PM
#5
Re: form wont unload?
make sure no other code is execute in the sub you call unload me, this can keep the program running, if in doubt use
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Aug 3rd, 2006, 11:44 PM
#6
Re: form wont unload?
when you run it in step by step by pressing F8, what happens...
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
-
Aug 3rd, 2006, 11:49 PM
#7
PowerPoster
Re: form wont unload?
 Originally Posted by ganeshmoorthy
when you run it in step by step by pressing F8, what happens...
I agree
-
Aug 4th, 2006, 02:34 AM
#8
PowerPoster
Re: form wont unload?
Either ..
VB Code:
'// UNLOAD FORM
Private Sub Form_Unload(Cancel As Integer)
'// END TIMER IF YOU HAVE
' Timer1.Interval = 0
' Timer1.Enabled = False
'// CLOSE ANY OPEN CONN
Winsock1.Close
'// UNLOAD ALL FORMS
Do Until Forms.Count = 1
Unload Forms(Forms.Count - 1)
Loop
End Sub
Or ... something like this .. depends what forms and controls you have ..
VB Code:
Private Sub form_unload(Cancel As Integer)
Dim ctl As Control
For Each ctl In Me.Controls
If TypeOf ctl Is Timer Then ' stop timers
ctl.Interval = 0
ctl.Enabled = False
End If
If TypeOf ctl Is Winsock Then ' close winsocks
ctl.Close
End If
Next
' unload all forms
Do Until Forms.Count = 1
Unload Forms(Forms.Count - 1)
Loop
End Sub
-
Aug 4th, 2006, 04:39 AM
#9
Thread Starter
Lively Member
Re: form wont unload?
works a treat, thanks guys
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|