pause?

D

djc

Is there a way to pause execution and then restart, and pause, and
restart..etcc?

sounds funny I'm sure but I am making a little graphical bar out of a group
of small text boxes and to do this I want to change the color of the first
one, pause for a specified interval, then change the color of the second,
then pause... etc...

I know I could insert a simple for...next loop to just count away to
simulate a pause but I was wondering if there was a better way? Since I just
want to pause, I don't want to have to actually take up system resources
with the for...next processing.

anyone know of anything?
 
K

Kelvin

Name all your text boxes for the graphical bar to use common names like
Box1, Box2, etc... Then define a global variable to keep track of the
numbers. Using the timer function of the form, call a routine that will
change the box referred to by the variable, then increment the variable so
that the next timer event will change the next box.

Kelvin
 
D

djc

kevin,

I wound up doing somthing similar to this however I could not figure out how
to just effect the next box... I did name them like box1, box2, etc... as
you said but I could not figure out how to access the appropriate box in
code based on the name? For example I had a string variable holding the
appropriate box to effect next but using something like
StringVarName.BackColor would not work. I wound up using the tag property of
the textboxes and looped through all the controls on the form. I did use a
global var as you said but I use it to know which tag value to check for
next.

how could I do this without using the tag value? Then I could avoid looping
through unnecessary controls. It does work but I am curious about what I was
missing before.
 
K

Kelvin

I think the correct method is:

Dim ctlTemp as Control
Dim intIndex as Integer
intIndex = 1

set ctlTemp = "Box" & intIndex
ctlTemp.BackColor = acGreen

Only controls can have the .BackColor property. If you were using a string
then NameOfString.BackColor would be invalid.

Kelvin
 
D

djc

Thanks!

Kelvin said:
I think the correct method is:

Dim ctlTemp as Control
Dim intIndex as Integer
intIndex = 1

set ctlTemp = "Box" & intIndex
ctlTemp.BackColor = acGreen

Only controls can have the .BackColor property. If you were using a string
then NameOfString.BackColor would be invalid.

Kelvin

property variable Since
 
D

djc

kelvin,

I get a 'type mismatch' error when attempting this? Are you supposed to be
able to assign a string value to a variable of type control? I did try the
Cstr(var) function but still got the error?

example:

set ctl = "myTextBox" & Cstr(gMyIndex)

ctl is a var of type control and gMyIndex is an integer.

do you know what the problem is?

thanks agian.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top