Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 22nd, 2008, 10:24 AM
Authorized User
 
Join Date: Nov 2005
Location: , , United Kingdom.
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default Show Form2, only then run Routine1

Hello,
I was wondering how can I press Button1 in VB.NET 2005 and get my software to 1st show Form2 and then run Routine1, but only run Routone1 after Form2 is shown on the screen.

1. Show Form2
2. Run a Routine1.

The problem I'm having is that when I press Button1 it runs 1 & 2 but shows Form2 after it has finished processing Routine1.

Actually Form2 is an animated timer that says 'Please wait, processing your data'. Routine1 is 4 very complicated cross table SQL queries that takes about 9 seconds to complete.

I basically want to show Form2 then run Routine1 on one button press and not two button presses.

Any help would be greatful as it does not matter how much I try, Form2 only ever shows 9 seconds after I press Button1. 9 seconds is the amount of time it takes to process the SQL queries.

Thank you for any help in advance.
__________________
Simplicity is the key
Reply With Quote
  #2 (permalink)  
Old March 18th, 2008, 06:43 AM
Authorized User
 
Join Date: Sep 2003
Location: Delhi, Delhi, India.
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to prabodh_mishra
Default

try calling Routine1 from within Form2


Prabodh
Reply With Quote
  #3 (permalink)  
Old March 18th, 2008, 07:02 AM
Authorized User
 
Join Date: Nov 2005
Location: , , United Kingdom.
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello,
I tried that and it didnt word. I ended up runing the timer as the last call thus running a seperate routine.

Simplicity is the key
Reply With Quote
  #4 (permalink)  
Old March 18th, 2008, 10:56 AM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

There are several things a form needs to do to be fully loaded and displayed. Most of those things raise events (Load, Activate, Resize, etc.)

You often can have one of these events change the value of a variable that some other process checks before running, thereby being able to cause it to "wait."

But since your routine takes so long to run, it seems that the form should be able to get its act together while the routine is running.

Many types of action tie up the processor, so that the screen effectively "freezes" until the action is done. In VB6 the way to overcome that is to add DoEvents to the routine. This is an explicit command to release the processor to service pending lower-priority acttions (like updating the screen).

In .NET use Application.DoEvents().

So what you would do is run the components in the order you indicated above. In routine 1, upon entry run DoEvents, and if yo uhave a loop in the routine put a DoEvents where it will run regularly. If no loop, sprinkle DoEvents throughout the routine.

BTW, it’s sep[u]a</u>rate, not sep[u]e</u>rate...
Reply With Quote
  #5 (permalink)  
Old April 8th, 2008, 02:44 PM
Authorized User
 
Join Date: Nov 2005
Location: , , United Kingdom.
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'll try that next week. Yes 'separate' was just a little typo error.

Simplicity is the key
Reply With Quote
  #6 (permalink)  
Old April 29th, 2008, 06:47 AM
Friend of Wrox
Points: 687, Level: 9
Points: 687, Level: 9 Points: 687, Level: 9 Points: 687, Level: 9
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2004
Location: Chennai, Tamilnadu, India.
Posts: 221
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Peter;

to state it- its something like this... say you have to update some 1000 records and when the update is going on-behind process, you have to show a form saying "process going on, please wait" and then process is completed automatically the form2 needs to get closed, so user comes to know the process is done.

is that correct?

If yes, to make it simple...
- u click button1 (process starts)
- u load form2 (animation)
- then add one timer which will starts automatically after the load of the form2
- then in the time after certain interval stop the timer and call the Routine1 in timer event.
- This will load the form2 first and calls the main routine.

look into this example of vb6, link; http://in.geocities.com/raghavendra_...ainRoutine.zip which will show these steps in action.

Hope this helps.


With Regards,
Raghavendra Mudugal
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
messagebox.show bikki_suresh ASP.NET 1.0 and 1.1 Basics 3 March 20th, 2008 04:26 AM
How can I run or not run Google AD in my ASP.NET w mycwcgr ASP.NET 2.0 Professional 0 November 5th, 2007 07:18 AM
How to show all available printers name? vijaykumartaduri General .NET 1 October 13th, 2006 12:03 AM
Show text from Form3 Textbox1 to Form2 Textbox1 peterasimpson VB How-To 5 December 19th, 2005 06:41 PM
Show server control at run time minhpx General .NET 1 March 2nd, 2005 12:08 PM



All times are GMT -4. The time now is 04:09 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.