This is what it's called "Memory leak". There are objects or even entire form(s) which were not unloaded from memory. You should never use the END instruction to finish your application. Be sure you unload all the forms, and destroy each object you've loaded into memory. Once you've done this... your program will just end pacefully.
Emiliano F. Martín
If a post has helped you then pleaseRate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
theres 4 forms, main menu, login form, register form. and a terms and conditions form.
starts on main menu, theres 2 radio buttons and a command buttong. dpending on what radio button is choosen the login or register form will open. and the terms and conditions form loads by clicking on a label on the register form...sorry im rubbish at explaining...
theres 4 forms, main menu, login form, register form. and a terms and conditions form.
starts on main menu, theres 2 radio buttons and a command buttong. dpending on what radio button is choosen the login or register form will open. and the terms and conditions form loads by clicking on a label on the register form...sorry im rubbish at explaining...
your not rubbish, if its simple could you post me yor app? as has been stated you may be using END which is bad practice.
If a post has helped you then pleaseRate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
You really shouldn't post your email address since spammers can pick it up.
It's been suggested that you create a zip file and upload it here so we can take a look at it. If you can create a zip (or rar) file then just click the Manage Attachments button and it will help you complete the upload.
thanks for that. well theres the files. has all the forms and everything so if someone could correct my mistakes and tell me what im doing wrong so i can understand it, it will save me goin wrong in the future. thanks
ok where do i put this code? ive put it at the top of the code in declarations and nothing, ive also tried putting it in the form_unload() part but i get compile errors
and ive tried
Private Sub Form_UnLoad()
Unload Me
End Sub
but i get an error saying "procedual declaration does not match description of event or procedure having the same name" which is problyc cause i dont have a button that unloads the form. i just want to end the program by closing it using the X at the top of the window
Last edited by ultimate165; Nov 26th, 2005 at 02:04 PM.
Sorry Pino but putting Unload Me in the form's Unload event isn't going to do anything since at that point the form is already unloading. Here is what you want to do. Put the following code in each forms QueryUnload event
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
VB Code:
Dim frm As Form
For Each frm In Forms
If frm.Name <> Me.Name Then
Unload frm
Set frm = Nothing
End If
Next
Unload Me
Set Form2 = Nothing ' Form2 should be changed to the name of the form where the code is
Or better yet add the following sub to a code module.
VB Code:
Public Sub UnloadAllForms(AForm As Form)
Dim frm As Form
For Each frm In Forms
If frm.Name <> AForm.Name Then
Unload frm
Set frm = Nothing
End If
Next
Unload AForm
Set AForm = Nothing
End Sub
and call it from each form's QueryUnload event like this
VB Code:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
heres the forms i have and everything can someone look thru them and just tell me what i should take out and what i should put in? thanks
I'm not surprised. Every time someone asks about closing forms (which is actually a very simple process) several people always chime in and often split hairs about what is right and what isn't which can be very confusing. So don't feel bad, it's not you, it's us.
I can't open rar files but if you can create a zip file I could help more.
You should start the code in Sub Main() in a module. Change the startup form to sub Main in project properties.
Then, in Sub Main, you would allow the user to log in. If he passes the login, you would load the next form. If he fails the login, then you don't do anything, and nothing is shown. Then, you only have to worry about the main form unloading.
Here is what I do. I give them 4 chances to get it right:
VB Code:
Sub Main()
LoginSucceeded = False
Do Until LoginSucceeded = True Or lcnt = 4
frmLogin.Show vbModal
Loop
If LoginSucceeded = True Then
frmMain.Show
End If
End Sub
Also, the screens didn't look right at 1024x768 resolution.
wow thanks. it seems to work now the only thing is i dont understand what i was doing wrong?
also the reason the interface may of looked funny was because i was using a custom font... how to i make it so other people get the custom font downloaded to thier font folder when they open up the program?
or better still be able to view the font without them downloading it
Basically there was something that was still in memory and wasn't unloaded. Lets take the smallest possible example:
- you have two forms, Form1 and Form2
- Form2 is opened from Form1
- Form2 has a button with code Me.Hide
- clicking this button will hide Form2, but not unload it
- you close Form1
- program stays open, because Form2 is still in memory although you can't see it
And the end result is that the program doesn't close. This is the case every time a program doesn't end properly: something is still in memory.
Another common mistake:
VB Code:
Private Sub cmdClose_Click()
Unload Me
SaveFile Text1.Text
End Sub
The problem here is that the form is unloaded once, but when you call Text1, the form is reloaded into the memory. And so the program doesn't end.