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
MSDN Subscribers: Download the VS 2010 Release Candidate
MSDN Subscribers: Download the VS 2010 Release Candidate
Sell Your Code and Make Money?
Creating your own Tetris game using VB.NET
Article :: Improving Software Economics, Part 4 of 7: Top 10 Principles of Iterative Software Management



Go Back   VBForums > Visual Basic > Visual Basic FAQs

Reply Post New Thread
 
Thread Tools Search this Thread Display Modes
Old Aug 31st, 2005, 01: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, 1067 views)

Last edited by si_the_geek; Aug 31st, 2005 at 01: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 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 On
HTML code is On

Forum Jump


All times are GMT -5. The time now is 11:56 AM.




To view more projects, click here

Acceptable Use Policy


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.