VBVB66

I am making a program with multiple forms. It runs very slowly when I try to load a new form. Is there any way to preload forms before letting the program be used Like a splash screen that loads all the forms without showing them before disappaering.


Re: Visual Basic Express Edition Preloading forms/controls

js06

Have you thought of using a background worker to load the forms

Load the main form first and then load the other forms with the backgroundworker in the main form load event

or use your screensaver as your main form and load all the forms with the background worker

you can have all the forms invisible while loading and then with the BackgroundWorker RunWorkerCompleted event you show the forms






Re: Visual Basic Express Edition Preloading forms/controls

vbvb66

But how do I load them without showing them




Re: Visual Basic Express Edition Preloading forms/controls

spotty

Think of a form as an Object. You can create an instance of a form without showing it by doing something as simple as

Dim x as new form1

x is now a instance of form1, its not visible until you either set its visible property to true or use the show/showdialog method.

I'm not sure how much you think preloading is going to buy you, I'd start by looking at what code you have there already and seeing if you can optimize this first.





Re: Visual Basic Express Edition Preloading forms/controls

vbvb66

I don't want a new instance. I want to preload my actual form.




Re: Visual Basic Express Edition Preloading forms/controls

js06

Ok you can do something like this

in the designer - set the opacity for each form that you want to load without seeing to 0

then you can use the form.show command for each one when you start your app whether you use the background worker or not

if you don't use the background worker then use form.show for each form in the load event of your main form

then when you want view a form - set the opacity to 100

form2.opacity = 100 instead of form.show

you can do the same with the background worker

in the do work event load all the forms

then in the runworkercomplete event show your main form

the whole flow would be like this

load splashscreen as startup form

in the load event for the splashscreen

me.backgroundworker1.runworkerasync

in the backgroundworker do work event

load the forms

form1.show

form2.show

etc...

runworkercomplete event

show your main working form

form1.opacity =100

form1.bringtofront

now you need to code the buttons to show the other forms with

form.opacity = 100

form.bringtofront

now instead of closing the forms you would

set the opacity to 0






Re: Visual Basic Express Edition Preloading forms/controls

vbvb66

It still runs slowly. Maybe that was not the problem.




Re: Visual Basic Express Edition Preloading forms/controls

js06

What part is slow

the initial loading or the showing of the forms after they are loaded






Re: Visual Basic Express Edition Preloading forms/controls

vbvb66

The problem is solved.





Re: Visual Basic Express Edition Preloading forms/controls

clint 2

vbvb66

can you tell us what the problem was and how you solved it

clint






Re: Visual Basic Express Edition Preloading forms/controls

vbvb66

I really don't know what the problem was or how it was solved. I just didn't work on the project for a while becuase I was frustrated, then after a while I started working on it again and the problem was gone, it loaded fine and ran fast.





Re: Visual Basic Express Edition Preloading forms/controls

js06

Now i understand what you are talking about

I had the same problem yesterday when i tried to run a database app

It took forever to load

I finally shutdown and restarted the computer

Now it works fine

it's a Windows thing i guess






Re: Visual Basic Express Edition Preloading forms/controls

vbvb66

I guess so.