WaitVBL in VB5 ???

Posted on 1998-02-18
Last Modified: 2009-07-29
I'm attempting to write a game in Visual Basic 5.
I need to ensure the game play rate is consistent and not too fast. I used to use Blitz Basic 2 on the Amiga and it had a "WaitVBL" command that was used to wait for the screens next complete vertical blank. Is this possible to achieve this with VB 5 ? If not, is it possible to ensure that a game will play at roughly the same speed on (say ) a P133 and a PII 233 ? Obviously, FOR... NEXT loops are not acceptable ;) I notice other games have been written with VB5, so somebody else must have overcome this very problem.
Question by:lbowers
  • 4
  • 3

Expert Comment

ID: 1457394
You can use SLEEP API (see below) to pause things for a desired number of milliseconds.  You can also use DOEVENTS to have windows complete actions in it's queue, to slow down your game.

Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal
dwMilliseconds As Long)


Author Comment

ID: 1457395
Edited text of question

Expert Comment

ID: 1457396
Unfortunately I don't think either Sleep or DoEvents will provide predictable periods.  Generally they provide a delay for a minimum amount of time, but exactly how long after that minimum it variable.
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.


Author Comment

ID: 1457397
You're right - I've tried using both of the prviously mentioned solutions and they both vary wildly on the actual time they delay for. It looks like it's not going to be possible with delving into Direct X perhaps...

Expert Comment

ID: 1457398
SLEEP API delays for the number of milliseconds you specify.  Nothing more, nothing less.

Author Comment

ID: 1457399

Sorry - You were right. The SLEEP API work perfectly!

How do I award you the points as I don't seem to be able to!
I can see no grading options either...

Accepted Solution

anthonyc earned 300 total points
ID: 1457400
You can give me points now!

Author Comment

ID: 1457401
Thanx a million!

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Specify ip address in my connection string for sas 2 58
Adding to a VBA? 6 69
How to measure sizes and angles in scanned images ? 3 63
IF ELSE Statement in Excel Macro VBA 16 62
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now