To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
VBForums  

VB Wire News
Part 10 of the Visual Basic .NET 2010 Express Tutorial Complete!
How to Use the Visual Studio Code Analysis Tool FxCop
Article :: Interview with Andrei Alexandrescu (Part 3 of 3)
Introducing Visual Studio LightSwitch
Visual Studio LightSwitch Beta 1 is Available



Go Back   VBForums > Visual Basic > Visual Basic FAQs

Reply Post New Thread
 
Thread Tools Display Modes
Old Aug 31st, 2005, 12:36 AM   #1
dglienna
Banned
 
dglienna's Avatar
 
Join Date: Jun 04
Location: Center of it all
Posts: 17,901
dglienna is a glorious beacon of light (400+)dglienna is a glorious beacon of light (400+)dglienna is a glorious beacon of light (400+)dglienna is a glorious beacon of light (400+)dglienna is a glorious beacon of light (400+)dglienna is a glorious beacon of light (400+)
Classic VB - How do I Pause my program?

Just like the Sleep command in Quick Basic, Visual Basic also lets you delay the execution of your code.

You do it by calling an API (Application Programming Interface) which are functions that are built into the Windows operating system.

The one needed here is the Sleep() API, which will pause execution of your program for the specified number of milliseconds (1000ms=1 second). In this example, the program is paused for 5 seconds when you click the button.

VB Code:
  1. Option Explicit
  2. 'This project needs a button
  3. Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
  4. Private Sub Command1_Click()
  5.     'KPD-Team 1998
  6.     'URL: [url]http://www.allapi.net/[/url]
  7.     'E-Mail: [email]KPDTeam@Allapi.net[/email]
  8.     Me.Caption = "Your system will sleep 5 sec."
  9.     'Sleep for 5000 milliseconds
  10.     Sleep 5000
  11.     Beep
  12.     Me.Caption = ""
  13. End Sub
  14. Private Sub Form_Load()
  15.     Me.Caption = ""
  16.     Command1.Caption = "Sleep ..."
  17. End Sub

A sample project is included below:
Attached Files
File Type: zip sleep.zip (1.1 KB, 1252 views)

Last edited by si_the_geek; Aug 31st, 2005 at 12:41 PM.
dglienna is offline   Reply With Quote
Reply

Go Back   VBForums > Visual Basic > Visual Basic FAQs


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 On
HTML code is On

Forum Jump


All times are GMT -5. The time now is 05:15 AM.





Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.