fredlo2010
12-19-2013, 05:58 PM
Hello guys,
I created a class to act as a timer but I am getting an error 28 Out of Stack space. I thought It was because I had a nested function. I removed that and I still get the same.
This is my class code:
Option Explicit'==================================
'Class Name: xlMyStopwatch
'Class Instancing: 1-Private
'==================================
' Declare the variables for the class
Private d_Start As Date
Private d_Final As Date
' Declare the properties for the class
Public Property Get timeStart() As Date
timeStart = d_Start
End Property
Public Property Get timeEnd() As Date
timeEnd = d_Final
End Property
Public Property Let timeStart(ByVal tStart As Date)
timeStart = tStart
End Property
Public Property Let timeEnd(ByVal tEnd As Date)
timeEnd = tEnd
End Property
' Methods and Functions
' Function to get the difference of time
' My original work contained a single function
'Public Function Difference(sInterval As String)
' Difference = DateDiff(sInterval, Me.timeStart, Me.timeEnd)
'End Function
Public Function ElapsedSeconds() As Long
ElapsedSeconds = DateDiff("s", Me.timeStart, Me.timeEnd)
End Function
Public Function ElapsedMinutes() As Long
ElapsedMinutes = DateDiff("m", Me.timeStart, Me.timeEnd)
End Function
Public Function ElapsedHours() As Long
ElapsedHours = DateDiff("h", Me.timeStart, Me.timeEnd)
End Function
Public Function ElapsedTime() As String
ElapsedTime = Format(Me.timeEnd - Me.timeStart, "hh:mm:ss")
End Function
and this is a sub I created and its giving me the error
Sub Create()
Dim myStopwatch As xlMyStopwatch
Set myStopwatch = New xlMyStopwatch
myStopwatch.timeStart = Now '<========== Running out of space error 28
' A small sample of dunny code to try the class
For Each r In Range("A1:A40")
r.Value = 1
Next r
myStopwatch.timeEnd = Now
Debug.Print myStopwatch.ElapsedHours
Debug.Print myStopwatch.ElapsedMinutes
Debug.Print myStopwatch.ElapsedSeconds
Debug.Print myStopwatch.ElapsedTime
End Sub
Thanks in advance for all the help. :)
I created a class to act as a timer but I am getting an error 28 Out of Stack space. I thought It was because I had a nested function. I removed that and I still get the same.
This is my class code:
Option Explicit'==================================
'Class Name: xlMyStopwatch
'Class Instancing: 1-Private
'==================================
' Declare the variables for the class
Private d_Start As Date
Private d_Final As Date
' Declare the properties for the class
Public Property Get timeStart() As Date
timeStart = d_Start
End Property
Public Property Get timeEnd() As Date
timeEnd = d_Final
End Property
Public Property Let timeStart(ByVal tStart As Date)
timeStart = tStart
End Property
Public Property Let timeEnd(ByVal tEnd As Date)
timeEnd = tEnd
End Property
' Methods and Functions
' Function to get the difference of time
' My original work contained a single function
'Public Function Difference(sInterval As String)
' Difference = DateDiff(sInterval, Me.timeStart, Me.timeEnd)
'End Function
Public Function ElapsedSeconds() As Long
ElapsedSeconds = DateDiff("s", Me.timeStart, Me.timeEnd)
End Function
Public Function ElapsedMinutes() As Long
ElapsedMinutes = DateDiff("m", Me.timeStart, Me.timeEnd)
End Function
Public Function ElapsedHours() As Long
ElapsedHours = DateDiff("h", Me.timeStart, Me.timeEnd)
End Function
Public Function ElapsedTime() As String
ElapsedTime = Format(Me.timeEnd - Me.timeStart, "hh:mm:ss")
End Function
and this is a sub I created and its giving me the error
Sub Create()
Dim myStopwatch As xlMyStopwatch
Set myStopwatch = New xlMyStopwatch
myStopwatch.timeStart = Now '<========== Running out of space error 28
' A small sample of dunny code to try the class
For Each r In Range("A1:A40")
r.Value = 1
Next r
myStopwatch.timeEnd = Now
Debug.Print myStopwatch.ElapsedHours
Debug.Print myStopwatch.ElapsedMinutes
Debug.Print myStopwatch.ElapsedSeconds
Debug.Print myStopwatch.ElapsedTime
End Sub
Thanks in advance for all the help. :)