 |
 |

10-05-2002, 03:38 PM
|
|
Freshman
|
|
Join Date: Oct 2002
Posts: 46
|
|
Unloading and Loading Crappy Error :( Help!!!
|
Hello everyone,
I'm just having a crappy day today! Because this little error is really making me mad. Well i've been working on a MMORPG for awhile now and i'm programming the load screen where you log on it dosnt use DirectX but the rest of the program uses DirectX. I'm making for frmLogin do somthing like this...
Private Sub imgContinue_Click()
Load frmMain
If ConnErr = True Then
MsgBox "Error connecting to server, please check your connection or try afain in a few minutes.
ElseIf ConnErr = False Then
End If
End Sub
My frmMain Load routine goes through the basic check connection and if connected then start the main program and then it goes to full screen and you can play the game fine untill you escape and then when you escape it shows an error:
Runtime Error 364:
Object was Unloaded
Then it highlights Load frmMain in my imgContinue Sub Routine
I also have unloaded frmMain in other places of my program.
I have tried to reverse it and turn Form_Load in frmMain into a Public sub but then it ignores my Private Functions when I call it from my frmLogin.
Please help!! How can I load frmMain without this error and have all my Functions work correctly?
|
__________________
If I had a penny for everytime I was stuck in a program I'd probabally pay someone else to do it.
|

10-05-2002, 06:37 PM
|
 |
Hell's Angel
Retired Moderator * Guru *
|
|
Join Date: Jul 2001
Location: Yorkshire, UK
Posts: 10,394
|
|
You can not call Unload Me from form_load if the form was loaded using the load statement. However, once the Load statement has completely finished executing you can call Unload as normal.
The way around this to set a form level Public boolean flag in the form if the load fails. Eg:
Code:
Public bLoadFail As Boolean
Private Sub Form_Load()
If error occurred Then
bLoadFail = True
Exit Sub
End If
End Sub
Then in your sub main you just check the flag to and unload the form is it is set:
Code:
Sub Main()
Load frmMain
If frmMain.bLoadFail Then
Unload frmMain
Else
frmMain.Show
End If
End Sub
|
__________________
A wise one man once said "what you talking about dog breath"
|

10-05-2002, 06:40 PM
|
 |
Mostly Absent
* Expert *
|
|
Join Date: Jun 2002
Location: Christchurch, New Zealand
Posts: 2,006
|
|
|
Dunno if this would work, but you could always try frmMain.show, instead of Load frmMain.
This will load the form if it needs to then display it.
Otherwise, it's kinda tricky to figure out without the code.
Jim
|
__________________
Sometimes it happens feelings die, Whole years are lost in the blink of an eye
We once had it all but event conspired, Sometimes
Now that it's over, it is through, It gets me everytime I think of you
Sometimes It happens, feelings die, Sometimes
|

10-05-2002, 07:00 PM
|
|
Freshman
|
|
Join Date: Oct 2002
Posts: 46
|
|
Banjo only problem with your suggestion is
Code:
If Error occurred Then <---
BLoadFail = True
Exit Sub
End If
How would I fix this?
And the other suggestion did the same thing
frm.Show had the same error "Form Unloaded"
|
__________________
If I had a penny for everytime I was stuck in a program I'd probabally pay someone else to do it.
|

10-06-2002, 04:45 AM
|
 |
Hell's Angel
Retired Moderator * Guru *
|
|
Join Date: Jul 2001
Location: Yorkshire, UK
Posts: 10,394
|
|
|
That line was not meant to be using literally, it was just a way of saying, "if an error has occurred in the load event then". How you decide on whether an error has occurred is up to you.
|
__________________
A wise one man once said "what you talking about dog breath"
|

10-07-2002, 09:04 PM
|
 |
Jedi Coder
* Expert *
|
|
Join Date: Aug 2002
Location: Abingdon, MD
Posts: 3,438
|
|
You can also use the Form_Activate event for checking since it occurs after the form is loaded. This is only good if you'll only be activating the form once. Usually it's best to do your checking outside of the form and only load the form if everything is good:
Code:
Sub Main()
Load frmMain 'in case you need the handle to the form
If InitializeStuff Then
frmMain.Show
End If
End Sub
|
|

10-08-2002, 07:25 AM
|
|
|
If you want help the i really need to see your code to see what the problem is 
|
|

10-08-2002, 08:46 AM
|
|
|
|
Is the procedure imgContinue_Click on frmMain by any chance?
|
|

10-08-2002, 05:00 PM
|
|
Freshman
|
|
Join Date: Oct 2002
Posts: 46
|
|
Hey
|
JimCamel was able to help me out and we got things going. Thanks alot to everyone who responded.
|
__________________
If I had a penny for everytime I was stuck in a program I'd probabally pay someone else to do it.
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|