Solved

reload a form

Posted on 2002-05-29
9
418 Views
Last Modified: 2008-03-03
Hi,
How can I close and reload the main form in my project without causing the application to completely exit.

In my case I want to close frmMain and Load frmMain but as soon as it is closed the project closes. Is there a way to do this?
0
Comment
Question by:adam8
  • 4
  • 3
  • 2
9 Comments
 
LVL 19

Accepted Solution

by:
Rimvis earned 50 total points
Comment Utility
It's maybe because you STARTUP FORM is frmMain. Try to change it to Sub Main and add some code that handles form reloading there.
0
 
LVL 2

Expert Comment

by:priya_pbk
Comment Utility
Why do you want to do this, if you are closing a form which is the main form in your application, that means you are closing your application. That's it!

Or do you want to something else, like refresing some variables. Just wanted to know why you are doing this, maybe there is a better way to accomplish.

-priya

0
 
LVL 1

Author Comment

by:adam8
Comment Utility
I want to clear listviews and image lists and all the variables on a form and so much stuff that i thought it would be easier to reload the form.

If I use a module and make Sub Main then wouldn't that mean I could keep a form running in the background. That way the app wouldn't close until the hidden form closed.

I am not sure
0
 
LVL 1

Author Comment

by:adam8
Comment Utility
Rimvis,I hadn't read your comment.

How would I go about this, I know how to start the app up from submain but how would I make sure teh application didn't close until i wanted it to.

Hopefully without using loops in the submain.
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 19

Expert Comment

by:Rimvis
Comment Utility
Here's a sample

Module1 code:
-------------------
Option Explicit

Sub Main()
    Form1.Show
End Sub

Public Sub Reload()
    Form1.Show
End Sub

Form1 code:
-----------------------
Option Explicit

Private Sub cmdTest_Click()
    Unload Me
    Reload
End Sub

----------------------------


Works for me :o)

0
 
LVL 1

Author Comment

by:adam8
Comment Utility
it works for me when I try it on a new prioject but doesn't work on my program. I will try again.

0
 
LVL 19

Expert Comment

by:Rimvis
Comment Utility
Maybe you have 'End' statement in your frmMain_Unload event?
0
 
LVL 2

Expert Comment

by:priya_pbk
Comment Utility
Try making the starup form as submain

Go to Project, Project Properties, General Tab, StartUp object as "Sub Main"

That maybe help!

0
 
LVL 1

Author Comment

by:adam8
Comment Utility
I know why, I had an End statement at the end of the Form_Unload statement to ensure it closed (what an idiot am I)

I feel a bit stupid now.

Thanks for the help.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now