Hi I'm developing a tiny application with vb5.0.
The app consists of now two forms. Form one(mainform) has a button, and
by clicking on this button the second form should be loaded.
the 2nd form, starts in fullscreen with black bg and should move a
square around the screen. In order to move the square I'm using a
do-until loop. One can return to the first screen by pressing the
ESC-button, then the loop stops and I leave the second form with unload
form2
I found this wierd bug:
When starting the loop directly in form_load() then I've to click
twice(!?) on the start button in the mainform to start the second form.
But If I remove the loop from form_load() and let it start manually with
e.g. form_onkeydown() the second form loads properly after the first
click on the start button in the main frame.
I don't know what's going wrong since I've got poor expierence with vb.
to start the second form I use the command form2.Show.
What do I have to change in order to start the loop directly when loading
Any Help welcome! Also If you need any further details!
Stefan
|
|
0
|
|
|
|
Reply
|
skoenig1 (1)
|
2/10/2007 5:56:28 PM |
|
In response to the post:
On Sat, 10 Feb 2007 18:56:28 +0100, Stefan K�nig <skoenig@web.de>
stated...and I replied:
>Hi I'm developing a tiny application with vb5.0.
>
>The app consists of now two forms. Form one(mainform) has a button, and
>by clicking on this button the second form should be loaded.
>
>the 2nd form, starts in fullscreen with black bg and should move a
>square around the screen. In order to move the square I'm using a
>do-until loop. One can return to the first screen by pressing the
>ESC-button, then the loop stops and I leave the second form with unload
>form2
>
>I found this wierd bug:
>When starting the loop directly in form_load() then I've to click
>twice(!?) on the start button in the mainform to start the second form.
>
>But If I remove the loop from form_load() and let it start manually with
>e.g. form_onkeydown() the second form loads properly after the first
>click on the start button in the main frame.
>
>I don't know what's going wrong since I've got poor expierence with vb.
>
>to start the second form I use the command form2.Show.
>
>What do I have to change in order to start the loop directly when loading
>
>Any Help welcome! Also If you need any further details!
>
>Stefan
The procedure to start up a program or object (As well, all
procedures), in an object structured world., has to terminate to allow
the system to continue working. An unfinished Load routine causes
problems. If you understand what I'm saying, you'll understand why
you provide closure for each routine, including the "Load" routine.
With that release, the load routine is completed and the system is
available for "Events". Now you can put what you want to continuously
loop for, inside the Timer event. No more Do...Loop inside the Load
event...Please. The Timer will provide a continuity until it is
stopped.
So, in order to provide a continuous procedure (Methods and Events of
the Object performed until stopped) started when the Load event stops,
you can use a Timer object and set it to fire often (About 200-500
Interval). Between firings the system is available to process other,
less intensive, events...like when someone clicks a button on form 1.
Hope this helps,
Shell
PS Keep your routines short and to the point. If one gets too big,
find a way to split it up into 2 or more seperate routines.
|
|
0
|
|
|
|
Reply
|
drshell (102)
|
2/10/2007 9:23:51 PM
|
|