Solved

WaitVBL in VB5 ???

Posted on 1998-02-18
8
268 Views
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.
0
Comment
Question by:lbowers
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 6

Expert Comment

by:anthonyc
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)

0
 

Author Comment

by:lbowers
ID: 1457395
Edited text of question
0
 
LVL 3

Expert Comment

by:rmichels
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.
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

Author Comment

by:lbowers
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...
0
 
LVL 6

Expert Comment

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

Author Comment

by:lbowers
ID: 1457399
Anthony...

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...
0
 
LVL 6

Accepted Solution

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

Author Comment

by:lbowers
ID: 1457401
Thanx a million!
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses
Course of the Month4 days, 7 hours left to enroll

635 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