Let's say I wanted to display the numbers between 1 and 1000. In qbasic I would do the following:
---------------
For X = 1 to 1000
Print X
Next X
---------------
It continually updates and prints X.
In vb, if I want basically the same thing, I type this:
-------------
For X = 1 to 1000
Label1.Caption = X
Next X
-------------
Problem here is that it doesn't print 1-2-3 etc, it just goes until it's finished and prints 1000.
Solution? Timers. Or are they?
To create the effect I want I have always had to do this:
------------
In the General Declarations:
Dim X as Integer
In a command button:
X = 0
Timer1.Enabled = True
In timer1:
X = X + 1
Label1.Caption = X
If X = 1000 Then Timer1.Enabled = False
-------------
This seems extremely inefficient, and those timer intervals appear to be sort of inconsistent. There's got to be an alternative, what is it?




Reply With Quote