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
------------------------------------------------- 5 3545
First of all, Date is an alias for System.DateTime which holds a point in
time which of course has a date part and a time part. If you want to use one
part or the other you MUST 'screen' the unwanted part out.
The declaration of the array can be simplified like:
Dim strPloegLetters As String() = New String() {"A", "D", "B", "C"}
This will 'unclutter' your code.
To do the comparison against the time part as a string you need to do it
like:
Select Case tme.ToString("H H:mm:ss")
Case "05:30:00" To "13:29:59"
Otherwise you are not comparing apples with apples.
What is the rationale behind the way that i is calculated? I don't mean what
does it do. I mean what is the intent of the business rule.
By my reckoning you will get a different value for a given time today thna
you will get for the same time tomorrow.
" Screaming Eagles 101" <se*********@on line.pleasewrot e in message
news:fO******** *************** *******@scarlet .biz...
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
-------------------------------------------------
Thanks already for this.
It calculates which work shift (A,B,C,D) will be working on day x
in the morning, afternoon, nightshift at a certain time...
Example (I did not calculate, just explaining) :
Parsing 13th March 2007 as date, hour 17:15 as time,
will result in a letter A,B,C, or a D.
We know then that at that time for example the D-shift will be at work.
Our shifts work
in the morningshift from Friday to Thursday
in the afternoonshift from Wednesday to Tuesday
in the nightshift from Monday to Sunday.
Inbetween are the rest-days : for example last nightshift is Sunday and
one starts again on Wednesday in the afternoon shift,
last afternoon is on Tuesday and then starting in the morning shift on
Friday,
rest on Wednesday and Thursday...
--
Filip http://www.ww2airborne.net/
Official Site of the 101st Airborne - 463rd PFA
skype: airborne463pfa-fiwi
-------------------------------------------------
"Stephany Young" <noone@localhos tschreef in bericht
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
First of all, Date is an alias for System.DateTime which holds a point in
time which of course has a date part and a time part. If you want to use
one part or the other you MUST 'screen' the unwanted part out.
The declaration of the array can be simplified like:
Dim strPloegLetters As String() = New String() {"A", "D", "B", "C"}
This will 'unclutter' your code.
To do the comparison against the time part as a string you need to do it
like:
Select Case tme.ToString("H H:mm:ss")
Case "05:30:00" To "13:29:59"
Otherwise you are not comparing apples with apples.
What is the rationale behind the way that i is calculated? I don't mean
what does it do. I mean what is the intent of the business rule.
By my reckoning you will get a different value for a given time today thna
you will get for the same time tomorrow.
" Screaming Eagles 101" <se*********@on line.pleasewrot e in message
news:fO******** *************** *******@scarlet .biz...
>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 -------------------------------------------------
Cool ... so that makes it:
Public Function GetPloegLetter( dt as DateTime) As String
Dim i As Integer
Select Case dt.ToString("HH :mm:ss")
Case "05:30:00" To "13:29:59"
'Process morningshift
i = dt.Date.AddDays (1) \ 7 + 1
Case "13:30:00" To "21:29:59"
' Process afternoonshift
i = dt.Date.AddDays (10) \ 7 + 1
Case "21:30:00" To "23:59:59"
' Process nightshift < midnight
i = dt.Date.AddDays (-2)
Case "00:00:00" To "05:29:59"
' Process nightshift midnight
i = dt.Date.AddDays (-3)
End Select
Return (New String() {"A", "D", "B", "C"})((i \ 7) Mod 4)
End Function
" Screaming Eagles 101" <se*********@on line.pleasewrot e in message
news:q8******** *************** *******@scarlet .biz...
Thanks already for this.
It calculates which work shift (A,B,C,D) will be working on day x
in the morning, afternoon, nightshift at a certain time...
Example (I did not calculate, just explaining) :
Parsing 13th March 2007 as date, hour 17:15 as time,
will result in a letter A,B,C, or a D.
We know then that at that time for example the D-shift will be at work.
Our shifts work
in the morningshift from Friday to Thursday
in the afternoonshift from Wednesday to Tuesday
in the nightshift from Monday to Sunday.
Inbetween are the rest-days : for example last nightshift is Sunday and
one starts again on Wednesday in the afternoon shift,
last afternoon is on Tuesday and then starting in the morning shift on
Friday,
rest on Wednesday and Thursday...
--
Filip http://www.ww2airborne.net/
Official Site of the 101st Airborne - 463rd PFA
skype: airborne463pfa-fiwi
-------------------------------------------------
"Stephany Young" <noone@localhos tschreef in bericht
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
>First of all, Date is an alias for System.DateTime which holds a point in time which of course has a date part and a time part. If you want to use one part or the other you MUST 'screen' the unwanted part out.
The declaration of the array can be simplified like:
Dim strPloegLetters As String() = New String() {"A", "D", "B", "C"}
This will 'unclutter' your code.
To do the comparison against the time part as a string you need to do it like:
Select Case tme.ToString("H H:mm:ss") Case "05:30:00" To "13:29:59"
Otherwise you are not comparing apples with apples.
What is the rationale behind the way that i is calculated? I don't mean what does it do. I mean what is the intent of the business rule.
By my reckoning you will get a different value for a given time today thna you will get for the same time tomorrow.
" Screaming Eagles 101" <se*********@on line.pleasewrot e in message news:fO******* *************** ********@scarle t.biz...
>>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 -------------------------------------------------
Well thanks, you've been a great help, that's for sure !
There are 2 minor things which were to be adapted to let it work,
one was in the division by 7 and Mod 4, small change to have the correct
shift.
A second one is that VB2005 for a weird reason won't allow to divide a date
by a number anymore as was possible in VB6.
The number I got from that division : I found out it is the amount of days
between 31 December 1899 and the parsed date.
(a bit as Excel works) So, once found, it was easy to make a tiny new
Function to convert the date to a long-variable, and make the calculation
with the result.
Thanks again for helping !
This is the code fully and 110% working :-)
Public Function GetPloegLetter( ByVal dt As DateTime) As String
Dim l As Long
Select Case dt.ToString("HH :mm:ss")
Case "05:30:00" To "13:29:59"
'Process morningshift
l = DateToDays(dt.D ate, 1) \ 7 + 1
Case "13:30:00" To "21:29:59"
' Process afternoonshift
l = DateToDays(dt.D ate, 10) \ 7 + 1
Case "21:30:00" To "23:59:59"
' Process nightshift < midnight
l = DateToDays(dt.D ate, -2) \ 7
Case "00:00:00" To "05:29:59"
' Process nightshift midnight
l = DateToDays(dt.D ate, -3) \ 7
End Select
Return (New String() {"A", "D", "B", "C"})(l Mod 4)
End Function
Private Function DateToDays(ByVa l dte As Date, ByVal i As Integer) As
Long
Dim dteOld As Date = CDate("31/12/1899")
DateToDays = DateDiff(DateIn terval.Day, dteOld, dte.AddDays(i))
End Function
--
Filip http://www.ww2airborne.net/
Official Site of the 101st Airborne - 463rd PFA
skype: airborne463pfa-fiwi
-------------------------------------------------
"Stephany Young" <noone@localhos tschreef in bericht
news:ex******** ******@TK2MSFTN GP04.phx.gbl...
Cool ... so that makes it:
Public Function GetPloegLetter( dt as DateTime) As String
Dim i As Integer
Select Case dt.ToString("HH :mm:ss")
Case "05:30:00" To "13:29:59"
'Process morningshift
i = dt.Date.AddDays (1) \ 7 + 1
Case "13:30:00" To "21:29:59"
' Process afternoonshift
i = dt.Date.AddDays (10) \ 7 + 1
Case "21:30:00" To "23:59:59"
' Process nightshift < midnight
i = dt.Date.AddDays (-2)
Case "00:00:00" To "05:29:59"
' Process nightshift midnight
i = dt.Date.AddDays (-3)
End Select
Return (New String() {"A", "D", "B", "C"})((i \ 7) Mod 4)
End Function
" Screaming Eagles 101" <se*********@on line.pleasewrot e in message
news:q8******** *************** *******@scarlet .biz...
>Thanks already for this.
It calculates which work shift (A,B,C,D) will be working on day x in the morning, afternoon, nightshift at a certain time...
Example (I did not calculate, just explaining) : Parsing 13th March 2007 as date, hour 17:15 as time, will result in a letter A,B,C, or a D. We know then that at that time for example the D-shift will be at work.
Our shifts work in the morningshift from Friday to Thursday in the afternoonshift from Wednesday to Tuesday in the nightshift from Monday to Sunday.
Inbetween are the rest-days : for example last nightshift is Sunday and one starts again on Wednesday in the afternoon shift, last afternoon is on Tuesday and then starting in the morning shift on Friday, rest on Wednesday and Thursday...
-- Filip http://www.ww2airborne.net/ Official Site of the 101st Airborne - 463rd PFA skype: airborne463pfa-fiwi -------------------------------------------------
"Stephany Young" <noone@localhos tschreef in bericht news:%2******* *********@TK2MS FTNGP03.phx.gbl ...
>>First of all, Date is an alias for System.DateTime which holds a point in time which of course has a date part and a time part. If you want to use one part or the other you MUST 'screen' the unwanted part out.
The declaration of the array can be simplified like:
Dim strPloegLetters As String() = New String() {"A", "D", "B", "C"}
This will 'unclutter' your code.
To do the comparison against the time part as a string you need to do it like:
Select Case tme.ToString("H H:mm:ss") Case "05:30:00" To "13:29:59"
Otherwise you are not comparing apples with apples.
What is the rationale behind the way that i is calculated? I don't mean what does it do. I mean what is the intent of the business rule.
By my reckoning you will get a different value for a given time today thna you will get for the same time tomorrow.
" Screaming Eagles 101" <se*********@on line.pleasewrot e in message news:fO****** *************** *********@scarl et.biz... 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 -------------------------------------------------
hey army fag
I would stay away from DOTNET
what Iraqis are doing to us army is just the same thing that MS did to
vb6 programmers
why would you continue giving them business?
FUCK MICROSOFT
WITH A SLEDGEHAMMER
On Feb 8, 12:02 am, " Screaming Eagles 101"
<see_my_s...@on line.pleasewrot e:
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
--
Filiphttp://www.ww2airborne .net/
Official Site of the 101st Airborne - 463rd PFA
skype: airborne463pfa-fiwi
-------------------------------------------------
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: R.Wieser |
last post by:
Hello All,
I'm trying to get a "Virtual Listbox" to work. I've currently got a form,
and used CreateWindowExA to create a ListBox with the LBS_OWNERDRAWFIXED and
LBS_NODATA flags on it. I've allso subclassed the window and do see all
kinds of WS_??? messages coming by.
But now I'm stuck :-\
I've got *no* idea what to do next, and all my searching on the web leads me
|
by: Paul T. RONG |
last post by:
Dear All,
I add two new tables to the database and then the disable shift key codes
don't work. These two new tables are actually created by two queries, and
only these two are in the front end, I didn't manage to move them to the
back end. I work with Access 2k under Win XP.
these are the codes that don't work (it worked for more than a year very
well):
|
by: Mehta Shailendrakumar |
last post by:
Hello,
Can anyone suggest me operator to perform arithmetic shift in C?
May it be for a perticular compiler.
Thank you in advance.
Regards,
Shailendra
|
by: Kenneth Lantrip |
last post by:
Anyone got any ideas as to how this process could be improved for speed?
this is what I have...
Dim j, q As Integer
Dim x(16), y(16) As Byte
x.CopyTo(y, 0) ' shift left circular 24 bits
|
by: Martin Jørgensen |
last post by:
Hi,
Consider:
------------
char stringinput
..bla. bla. bla.
do
{
| |
by: Matt Kowalczyk |
last post by:
How come this function doesn't work?
void shift(char** list, int index) {
char buff = (*list);
memmove((*list)+1, *list, index);
(*list) = buff;
return;
}
I call it like so:
|
by: sandhya |
last post by:
Hello Folks,
i hava a problem in coding of circular left shift of 25 bits in my
program...how do i perform it, and how do i use unsigned in VB.
My program (IDEA algorithm implementation in VB) requires unsigned
bits...so how do i go thro this ,since VB does not support unsigned
operations
Post your suggestions!!!
|
by: Jm lists |
last post by:
hello members,
See my script piece below:
def testB(shift,**argv):
print "first argument is %s" %shift
print "all other arguments are:",argv
testB('mails','Jen','Jen@att.com','Joe','Joe@aol.com')
|
by: aplata |
last post by:
My instructor has asked me to use the pop, shift, and push functions to write a script that sufficiently "shuffles" a simulated deck of cards before printing the top five cards.
I came up with the following code but the problem I am having is that I can't seem to shuffle by just using pop, push, and shift. I think the problem for me is trying to understand what constitutes a shuffle because there are many different ways to shuffle a deck of...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |