Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 13
Default User Form: Cannot Update Text Box

Greetings:

I am writing a user form that includes an Event Clock which I am
trying to implement as a Text Box that gets updated every second
with the current time.

When the form is open, the following code initializes the clock:

Public Sub UserForm_Initialize()
Application.OnTime Now + TimeValue("00:00:01"), "Display_Time"
End Sub

Now the Display_Time subroutine is defined and implemented in
code module of the User Form. When I step into this initialize sub-
routine, I get the following error:

The macro EventTimer.xls!Display_Time cannot be found.

I tried placing Display_Time subroutine in a separate code module,
but then got a run-time error complaning:

Run-time Error '424'
Object Required

Here's the Display_Time subroutine:

Public Sub Display_Time()
Dim CurTime, CurHour, CurMinute, CurSecond As Integer

CurTime = Now() Mod 1
CurHour = Int(CurTime * 24)
CurTime = (CurTime * 24) Mod 1
CurMinute = Int(CurTime * 60)
CurTime = (CurTime * 60) Mod 1
CurSecond = Int(CurTime * 60)

EventClock.Text = Format$(CurHour, "00") & ":" & _
Format$(CurMinute, "00") & ":" & Format$(CurSecond, "00")
Application.OnTime Now() + TimeValue("00:00:01"), "Display_Time"
End Sub

The run-time error appears to occur because the EventClock object
is undefined in the separate code module I created.

So my question is, where can I define a subroutine to be executed
every second that can succesfully update the EventClock object on
my User Form? Or on the other hand, how can I somehow make the
EventClock object known to my Display_Time subroutine so that I
don't get a run-time error when I attempt to update this object?

Respectfully,

Charles Ritz
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Baffling! Spreadsheet Data Form Size Jim Excel Discussion (Misc queries) 0 May 4th 06 07:41 PM
user form question: text box to display result BigPig Excel Discussion (Misc queries) 0 February 28th 06 12:33 AM
user form question: text box to display result BigPig Excel Worksheet Functions 0 February 25th 06 08:17 PM
Printing Part of User Form mully New Users to Excel 1 May 26th 05 08:22 AM
A "previous" button on a user form Anthony Slater Excel Discussion (Misc queries) 3 November 29th 04 05:57 PM


All times are GMT +1. The time now is 05:32 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"