私はまだこの問題に苦労しています。私はカスタムクラスモジュールであるTimeFrameとTimeSheetを使用しています。以下は短縮バージョンです。
_________________________
'TIMEFRAME CLASS MODULE
'This class records Military Time, but allows
'you to also display it in Civilian Time
Private pHours As Integer
Private pMinutes As Integer
Private pTotalMinutes As Integer
Public Property Get hours() As Integer
hours = pHours
End Property
Public Property Let hours(Value As Integer)
If Value >= 1 And Value <= 24 Then
pHours = Value
Else
Err.Raise 9009, , "Hours Value [" & CStr(Value) & "] is not valid."
End If
End Property
Public Property Get minutes() As Integer
minutes = pMinutes
End Property
Public Property Let minutes(Value As Integer)
If Value >= 0 And Value <= 59 Then
pMinutes = Value
Else
Err.Raise 9010, , "Minutes Value [" & CStr(Value) & "] is not valid."
End If
End Property
Public Property Let Initialize(str As String)
'This property expects a string formatted like: 08:30
Dim vhours As String
Dim vminutes As String
Dim arrTime() As String
If InStr(str, Me.Delimiter) Then
arrTime = Split(str, Me.Delimiter)
vhours = Trim(arrTime(0))
vminutes = Trim(arrTime(1))
If IsNumeric(vhours) Then
pHours = CInt(vhours)
End If
If IsNumeric(vminutes) Then
pMinutes = CInt(vminutes)
End If
Else
'Set to defaults
pHours = 0
pMinutes = 0
End If
End Property
...
_____________________________
'TIMESHEET CLASS MODULE
Private pEmployeeID As Integer
Private pStartDate As Date
Private pEndDate As Date
Private pMonStart As TimeFrame
Private pMonEnd As TimeFrame
Private pMonBreak As Double
Private pTuesStart As TimeFrame
Private pTuesEnd As TimeFrame
Private pTuesBreak As Double
Private pWedStart As TimeFrame
Private pWedEnd As TimeFrame
Private pWedBreak As Double
Private pThursStart As TimeFrame
Private pThursEnd As TimeFrame
Private pThursBreak As Double
Private pFriStart As TimeFrame
Private pFriEnd As TimeFrame
Private pFriBreak As Double
Public Property Get EmployeeID() As Integer
EmployeeID = pEmployeeID
End Property
Public Property Let EmployeeID(Value As Integer)
If Value > 0 Then
pEmployeeID = Value
Else
MsgBox "Employee ID " & Value & " is an incorrect value." & vbCrLf & "Employee ID must be a positive integer"
End If
End Property
Public Property Get StartDate() As Date
StartDate = pStartDate
End Property
Public Property Let StartDate(Value As Date)
pStartDate = Value
End Property
Public Property Get EndDate() As Date
EndDate = pEndDate
End Property
Public Property Let EndDate(Value As Date)
pEndDate = Value
End Property
Public Property Get MondayStart() As TimeFrame
Set MondayStart = pMonStart
End Property
Public Property Set MondayStart(ByRef Value As TimeFrame)
Set pMonStart = Value
End Property
Public Property Get MondayEnd() As TimeFrame
Set MondayEnd = pMonStart
End Property
Public Property Set MondayEnd(ByRef Value As TimeFrame)
Set pMonEnd = Value
End Property
Public Property Get MondayBreak() As Double
MondayBreak = pMonBreak
End Property
Public Property Let MondayBreak(Value As Double)
pMonBreak = Value
End Property
Public Property Get TuesdayStart() As TimeFrame
Set TuesdayStart = pTuesStart
End Property
Public Property Set TuesdayStart(ByRef Value As TimeFrame)
Set pTuesStart = Value
End Property
Public Property Get TuesdayEnd() As TimeFrame
Set TuesdayEnd = pTuesStart
End Property
Public Property Set TuesdayEnd(ByRef Value As TimeFrame)
Set pTuesEnd = Value
End Property
Public Property Get TuesdayBreak() As Double
TuesdayBreak = pTuesBreak
End Property
Public Property Let TuesdayBreak(Value As Double)
pTuesBreak = Value
End Property
...
メインモジュールでは、2つのサブルーチンを次々に呼び出しています。
- TimeSheetタイプのインスタンスを含むコレクションであるTimeSheetCollectionという名前のグローバル変数があります
- まず、TimeSheetCollectionオブジェクトを設定し、今日のメールアイテムを読み込み、メールアイテムの本文から取得した値から各TimeSheetのプロパティを設定するサブルーチンReadWeeklyTimeSheets()を呼び出します。このサブルーチンは正常に機能しています。
- 次に、ExportTimeSheetsToDatabase()という名前のサブルーチンが呼び出されます。Item.MondayStartプロパティとItem.MondayEndプロパティにエラーメッセージが表示されるいくつかのDebug.printステートメントを入力しました:「オブジェクトはこのプロパティまたはメソッドをサポートしていません」
メインモジュール:
Sub ExportTimeSheetsToDatabase()
Dim Item As TimeSheet
For Each Item In TimeSheetCollection
Debug.Print "TSCollection Count: " & TimeSheetCollection.count
Debug.Print Item.EmployeeID & ", " & Item.StartDate & ", " & Item.EndDate
Debug.Print Item.MondayStart '<<< Error occurs here
Debug.Print Item.MondayEnd
Debug.Print "Toal Hours: " & Item.TotalWeeklyHours
Next Item
End Sub
ItemのタイプはTimeSheetであるため、上記のクラスモジュールから、Getメソッドが含まれていることがわかります。
Public Property Get MondayStart() As TimeFrame
Set MondayStart = pMonStart
End Property
私の調査によると、構文は正しいように見え、ドット演算子「。」を入力すると アイテムの後に、すべてのプロパティが表示されたリストが表示されます。スペルを間違えたわけではありません。お知らせ下さい。
アラン