Dim Q As Single
Q = <floating-point computation>
…
If Q = <floating-point computation> then
...
End If
Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type
Function GetDatePart(struct As SYSTEMTIME, MemberName As String) As Integer
Select Case MemberName
Case "Year"
GetDatePart = struct.wYear
case "Month"
...
End Select
End Function
Function GetDatePart(t As SYSTEMTIME, ByRef tmember As Integer) As Integer
GetDatePart = tmember
End Function
Sub Test
Dim t As SYSTEMTIME
t.wYear = 2005
t.wMonth = 8
t.wDay = 10
MsgBox GetDatePart(t, t.wMonth)
End sub
Private Function GetDatePart(t As SYSTEMTIME, ByVal tmember As Integer) As Integer
GetDatePart = tmember
End Function
Sub Test
Dim t As SYSTEMTIME
Dim t2 As SYSTEMTIME
t.wYear = 2005
t.wMonth = 8
t.wDay = 10
MsgBox GetDatePart(t2, t.wMonth)
End sub
Public Property Get Month() As Variant
Dim t As SYSTEMTIME
Month = GetDatePart(t, t.wMonth)
End Property
Public Property Get Day() As Variant
Dim t As SYSTEMTIME
Day = GetDatePart(t, t.wDay)
End Property
Public Property Get Hour() As Variant
Dim t As SYSTEMTIME
Hour = GetDatePart(t, t.wHour)
End Property
Public Property Get Minute() As Variant
Dim t As SYSTEMTIME
Minute = GetDatePart(t, t.wMinute)
End Property
Public Property Get Second() As Variant
Dim t As SYSTEMTIME
Second = GetDatePart(t, t.wSecond)
End Property
Private Function GetDatePart(t As SYSTEMTIME, ByRef tmember As Integer) As Variant
If SendMessage(h, DTM_GETSYSTEMTIME, 0, t) = GDT_VALID Then
GetDatePart = tmember
Else
GetDatePart = Null
End If
End Function
GSerg писал(а):и как byval, и как byref
SendMessage(h, DTM_GETSYSTEMTIME, 0, t) = GDT_VALID
GSerg писал(а):Ы?
Public Property Get Second() As Variant
Second = GetDatePart.wSecond
End Property
Private Function GetDatePart() As SYSTEMTIME
Dim t As SYSTEMTIME
...
GetDatePart = t
End Function
Igor_123 писал(а):Так то оно может проще
GSerg писал(а):Обращаем внимание на код.
Видим, что в случае, когда не GDT_VALID, возвращается Null.
Ы?
Сейчас этот форум просматривают: Yandex-бот и гости: 127