OnTime...Please Help

  • Thread starter Thread starter Michael_I
  • Start date Start date
M

Michael_I

Hello!

I am working with a cognitive psychology test, which will serve as a
independant variable. The test runs a userform which consists of
random number and a random data set (consisting of 5 numbers). I hav
all of the fuctionallity setup except for the delay between the rando
number and the data set.

I would like the userform to open, display the random number for (2
seconds, then delete it from the text box. (1) second later the dat
set is shown for (1) second, then delete it from the test box.

The tricky part is to start the timer at the time the dataset is show
up until the participate presses the appropriate selection

I have attached the document I am using...

Thanks,
Mik

Attachment filename: cog test.zip
Download attachment: http://www.excelforum.com/attachment.php?postid=55346
 
Michael,

Here is a simple example to set the textbox

Dim starttime As Double

Private Sub CommandButton1_Click()

TextBox1.Text = "Another value"

starttime = Now + TimeSerial(0, 0, 1)
Application.OnTime starttime, "clearTextbox", schedule:=True

End Sub

Private Sub UserForm_Activate()

TextBox1.Text = "Some value"

starttime = Now + TimeSerial(0, 0, 2)
Application.OnTime starttime, "clearTextbox", schedule:=True

End Sub

and you also need a procedure in a standard module that reacts to the OnTime
method

Sub clearTextbox()
UserForm1.TextBox1.Text = ""
End Sub


Also, take a look at www.cpearson.com/excel/ontime.htm for more details.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Hello Bob!

I like the way you explained the solution! I have been through th
code that you have provided along with the code on Chip's site. I a
still running into a problem. I can get both textboxes that I a
working with to display the random number and also the dataset and the
clear the text box. The problem that I am running into is that the
display at the same time. I need textbox1 to be displayed, the
textbox2. This has to happen without the use of another button (i
must run when the userform initializes).

Any suggestions how to make a pause, delete textbox1 the show textbox
- while in the same module? I was thinking that I could just call th
ontime to create the pause, but it does not seem to be working.

Thanks,
Mik
 
Michael,

Try this version

Dim endTime As Double

Private Sub UserForm_Activate()

TextBox1.Text = "Some value"

endTime= Now + TimeSerial(0, 0, 2)
Application.OnTime endTime , "clearTextbox1", schedule:=True

End Sub

as before, you need a procedure (actually two) in a standard module that
reacts to the OnTime
method

Sub clearTextbox1()

With UserForm1
.TextBox1.Text = ""
.TextBox2.Text = "Another value"
End With

endTime = Now + TimeSerial(0, 0, 1)
Application.OnTime endTime , "clearTextbox2", schedule:=True

End Sub


Sub clearTextbox2()
UserForm1.TextBox2.Text = ""
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
o.k....this is really starting to hurt my head.

It seems that everything should be working with the appropriate code
but it is not. The first value is showing, and staying...nothing else
 
Michael,

Why not send we the workbook, and I'll take a look at it?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Michael,

I will need your email address as I do not post attachments to the NG, and I
cannot see it through the ExcelForum layer.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Thanks Michael, response in the mail.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

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

Back
Top