|
-
Apr 22nd, 2000, 03:37 AM
#1
Here is a simple way to make your program wait during an action.
First add a timer to your form. Call it Timer1. Sey its interval to 0 and its enabled property to FALSE.
Then add this subroutine.
------------------------------------------------------------
Public Sub Wait(seconds)
'-- Turn Timer On
Timer1.Enabled = True
'-- Set Timer Interval
Me.Timer1.Interval = 1000 * seconds
While Me.Timer1.Interval > 0
Do Events
Wend
'-- Turn Timer Off
Timer1.Enabled = False
End Sub
------------------------------------------------------------
Now when you want to use it just put in a line like this in a buttons Click() action.
Wait (5) '-- To Wait 5 seconds
If it doesnt work, check for spelling, i might have spelled something wrong. Hope it helps someone...
-
Apr 22nd, 2000, 04:46 AM
#2
Hyperactive Member
You can use API function Sleep for that.
-
Apr 22nd, 2000, 05:20 AM
#3
transcendental analytic
Or make a loop with GetTickCount
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Apr 22nd, 2000, 10:53 AM
#4
Hyperactive Member
You have to be careful about where your using the timer, its only accurate to 55 ms so its not useful for some applications.
"People who think they know everything are a great annoyance to those of us who do."
-
Apr 22nd, 2000, 11:00 AM
#5
Addicted Member
hey, noone, are you 'no one' or 'noone'? just wondering if you're perfect or not =)
-
Apr 22nd, 2000, 03:03 PM
#6
transcendental analytic
The timer control is based on the timer function which is not sensitive enough (updates about every 55ms). GetTickCount API updates exactly each ms.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Apr 23rd, 2000, 12:43 AM
#7
How?
Whats an API, and how do i use GetTickCount?
-
Apr 23rd, 2000, 01:21 AM
#8
transcendental analytic
Put this into your declarations:
Code:
Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long
API =Advanced Programmers Interface, But when we say An API, we mean a function (or sub) that we declare to use in user32.dll, kernel32.dll, gdi32.dll, advapi32.dll....I don't know them all. Gettickcount function should return a millisecond sensitive value for you.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Apr 23rd, 2000, 12:20 PM
#9
Hyperactive Member
Is that what API stands for? I always thought the 'A' stood for application, not advanced. Oh well, I could be(probably am) wrong.
Back on topic, I remember reading somewhere about an API Multimedia Timer that was also accurate to 1 ms, but whenever I used it my program just crashed. Does anyone else know what Im talking about?
"People who think they know everything are a great annoyance to those of us who do."
-
Apr 23rd, 2000, 02:57 PM
#10
transcendental analytic
Im not sure either what the A stands for, I've thought it was "Advanced", don't remember who told me that. I had one timer to but didn't like it. Evalution thing. I've had an vbx too.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Apr 23rd, 2000, 05:07 PM
#11
Fanatic Member
API is 'Application Programming Interface'
Which is usually the published entry points to DLL files in a certain product.
Be careful with the Sleep API though because it will stall the app from redraws etc too which can look poor if part of you app gets temporarily covered. If timing to the Nth degree isn't so important, the while loop with DoEvents is usually fine.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|