Time Function Problem

Tech-Archive recommends: Fix windows errors by optimizing your registry



I can get the Date function to work but the time Function returns the
following error at the line MyTime = Time

Run time error 450 Wrong number of arguments or invalid property assignment




Here is my code:



Private Sub cmdClickHere_Click()
Dim MyDate As Date

MyDate = Date
lblTime.Caption = MyDate

End Sub

'The above works and returns the correct value


Private Sub cmdClickHere2_Click()

Dim MyTime As Variant

MyTime = Time
lblTime2.Caption = MyTime

End Sub

'This Crashes



What am I doing wrong??

If I set the Dim MyTime as Time it still crashes with the following message:

Compile Error: Function or interface marked as restricted or the function
uses an automation type not supported in Visual Basic.


.



Relevant Pages

  • Re: Help with code - countdown timer
    ... Private bStopTimer As Boolean ... Dim WarningTime As Integer ... Dim MyTime As Double ... Private Sub Worksheet_Change ...
    (microsoft.public.excel.programming)
  • Re: Help with code - countdown timer
    ... would display the timer and D4 would display the text? ... Private bStopTimer As Boolean ... Dim MyTime As Double ... Private Sub Worksheet_Change ...
    (microsoft.public.excel.programming)
  • Re: Help with code - countdown timer
    ... timed test and countdown timer is better for our purposes. ... Private bStopTimer As Boolean ... Dim MyTime As Double ... Private Sub Worksheet_Change ...
    (microsoft.public.excel.programming)
  • Re: Help with code - countdown timer
    ... would display the timer and D4 would display the text? ... Private bStopTimer As Boolean ... Dim MyTime As Double ... Private Sub Worksheet_Change ...
    (microsoft.public.excel.programming)
  • Re: Help with code - countdown timer
    ... Private bStopTimer As Boolean ... Dim WarningTime As Integer ... Dim MyTime As Double ... Private Sub Worksheet_Change ...
    (microsoft.public.excel.programming)