Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Game Programming > Unloading and Loading Crappy Error :( Help!!!


Reply
 
Thread Tools Display Modes
  #1  
Old 10-05-2002, 03:38 PM
kentheprogger kentheprogger is offline
Freshman
 
Join Date: Oct 2002
Posts: 46
Exclamation 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.
Reply With Quote
  #2  
Old 10-05-2002, 06:37 PM
Banjo's Avatar
Banjo Banjo is offline
Hell's Angel

Retired Moderator
* Guru *
 
Join Date: Jul 2001
Location: Yorkshire, UK
Posts: 10,394
Default

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"
Reply With Quote
  #3  
Old 10-05-2002, 06:40 PM
JimCamel's Avatar
JimCamel JimCamel is offline
Mostly Absent

* Expert *
 
Join Date: Jun 2002
Location: Christchurch, New Zealand
Posts: 2,006
Default

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
Reply With Quote
  #4  
Old 10-05-2002, 07:00 PM
kentheprogger kentheprogger is offline
Freshman
 
Join Date: Oct 2002
Posts: 46
Default

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.
Reply With Quote
  #5  
Old 10-06-2002, 04:45 AM
Banjo's Avatar
Banjo Banjo is offline
Hell's Angel

Retired Moderator
* Guru *
 
Join Date: Jul 2001
Location: Yorkshire, UK
Posts: 10,394
Default

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"
Reply With Quote
  #6  
Old 10-07-2002, 09:04 PM
Machaira's Avatar
Machaira Machaira is offline
Jedi Coder

* Expert *
 
Join Date: Aug 2002
Location: Abingdon, MD
Posts: 3,438
Default

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
Reply With Quote
  #7  
Old 10-08-2002, 07:25 AM
Ozzman
Guest
 
Posts: n/a
Default

If you want help the i really need to see your code to see what the problem is
Reply With Quote
  #8  
Old 10-08-2002, 08:46 AM
ardman
Guest
 
Posts: n/a
Default

Is the procedure imgContinue_Click on frmMain by any chance?
Reply With Quote
  #9  
Old 10-08-2002, 05:00 PM
kentheprogger kentheprogger is offline
Freshman
 
Join Date: Oct 2002
Posts: 46
Default 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.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->