S
Screaming Eagles 101
Hi,
I'm looking for some code to find the right work shift according to a
specific date and time.
This one worked fine in VB6, but somewhere I do not succeed in converting it
to VB2005 code....
Public Function GetPloegLetter(dte As Date, tme As Date) As String
'dte is the date, tme is the time of the shift.
Dim strPloegLetters(3) As String
strPloegLetters(0) = "A"
strPloegLetters(1) = "D"
strPloegLetters(2) = "B"
strPloegLetters(3) = "C"
Dim i As Integer
'Get the right shift for the parsed date and time...
Select Case tme
Case "05:30:00" To "13:29:59"
'Process morningshift
i = (((dte + 1) \ 7) + 1) Mod 4
GetPloegLetter = strPloegLetters(i)
Case "13:30:00" To "21:29:59"
'Process afternoonshift
i = (((dte + 10) \ 7) + 1) Mod 4
GetPloegLetter = strPloegLetters(i)
Case "21:30:00" To "23:59:59"
'Process nightshift < midnight
i = ((dte - 2) \ 7) Mod 4
GetPloegLetter = strPloegLetters(i)
Case "00:00:00" To "05:29:59"
dte = dte - 1 ' we need the day before
'Process nightshift > midnight
i = ((dte - 2) \ 7) Mod 4
GetPloegLetter = strPloegLetters(i)
End Select
End Function
--
Filip
http://www.ww2airborne.net/
Official Site of the 101st Airborne - 463rd PFA
skype: airborne463pfa-fiwi
-------------------------------------------------
I'm looking for some code to find the right work shift according to a
specific date and time.
This one worked fine in VB6, but somewhere I do not succeed in converting it
to VB2005 code....
Public Function GetPloegLetter(dte As Date, tme As Date) As String
'dte is the date, tme is the time of the shift.
Dim strPloegLetters(3) As String
strPloegLetters(0) = "A"
strPloegLetters(1) = "D"
strPloegLetters(2) = "B"
strPloegLetters(3) = "C"
Dim i As Integer
'Get the right shift for the parsed date and time...
Select Case tme
Case "05:30:00" To "13:29:59"
'Process morningshift
i = (((dte + 1) \ 7) + 1) Mod 4
GetPloegLetter = strPloegLetters(i)
Case "13:30:00" To "21:29:59"
'Process afternoonshift
i = (((dte + 10) \ 7) + 1) Mod 4
GetPloegLetter = strPloegLetters(i)
Case "21:30:00" To "23:59:59"
'Process nightshift < midnight
i = ((dte - 2) \ 7) Mod 4
GetPloegLetter = strPloegLetters(i)
Case "00:00:00" To "05:29:59"
dte = dte - 1 ' we need the day before
'Process nightshift > midnight
i = ((dte - 2) \ 7) Mod 4
GetPloegLetter = strPloegLetters(i)
End Select
End Function
--
Filip
http://www.ww2airborne.net/
Official Site of the 101st Airborne - 463rd PFA
skype: airborne463pfa-fiwi
-------------------------------------------------