Hello All,
I'm writing an app to track file transfer activity.
I have this enum to represent days of the week:
Monday = 1
Tuesday = 2
Wednesday = 3
Thursday = 4
Friday = 5
Saturday = 6
Sunday = 7
If a file should be transferred on a Monday and Friday, I add 1 to 5
and store 6.
How do I go back the way ?
e.g. I have a value of 6, how to get Monday and Friday ?
Pointers appreciated!
Regards
hharry 3 6390
You need to use bitwise values, i.e.
[Flags]
public enum Days {
None = 0,
Monday = 1, Tuesday = 2, Wednesday = 4, Thursday = 8,
Friday = 16, Saturday = 32, Sunday = 64
}
Then "Monday and Friday" (in English) is Days.Monday | Days.Friday
To convert as a number, just cast:
int value = (int) days;
Days days = (Days) value;
To check for individual days:
if((days & Days.Tuesday) == Days.Tuesday)
Marc
You have to make the values assigned to particular days subsequent powers of 2
You can then put the [Flags] attribute on the enum:
[Flags]
enum DaysOfWeek {
Monday = 1,
Tuesday = 2,
Wednesday = 4,
Thursday = 8,
Friday = 16,
Saturday = 32,
Sunday = 64
}
Then you can do sth like this:
DaysOfWeek dd = DaysOfWeek.Monday | DaysOfWeek.Friday;
You can also check if a given value "contains" Monday in it:
if ((dd & DaysOfWeek.Monday) == DaysOfWeek.Monday) { // do sth }
Hope this helps,
_____________
Adam Bieganski http://godevelop.blogspot.com
"hharry" wrote:
Hello All,
I'm writing an app to track file transfer activity.
I have this enum to represent days of the week:
Monday = 1
Tuesday = 2
Wednesday = 3
Thursday = 4
Friday = 5
Saturday = 6
Sunday = 7
If a file should be transferred on a Monday and Friday, I add 1 to 5
and store 6.
How do I go back the way ?
e.g. I have a value of 6, how to get Monday and Friday ?
Pointers appreciated!
Regards
hharry
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: androtech |
last post by:
Hello,
I'm looking for a function that returns a date range for a specified week
number of the year.
I'm not able to find functions like this anywhere. Any pointers/help would
be much...
|
by: SimonC |
last post by:
I would like to return data from the last 2 weeks of each given month
in Javascript, but in 2 formats.
So, the penultimate week (Monday to Sunday) and the last week (Monday
to ??)
I'm not...
|
by: Shuffs |
last post by:
Could someone, anyone please tell me what I need to amend, to get this
function to take Sunday as the first day of the week?
I amended the Weekday parts to vbSunday (in my code, not the code...
|
by: deko |
last post by:
This runs, but does not narrow to current week.
suggestions appreciated!
SELECT lngEid, dtmApptDate, Subject, Appt_ID
FROM qry002
WHERE (dtmApptDate BETWEEN
DateAdd("d",-weekday()+2,) And...
|
by: Ty Smith via AccessMonster.com |
last post by:
I noticed that the week numbers in Stephan Leban's MonthCalendar are not consistent with Microsoft Outlook (they are shifted one week forward). Is there any way I can sync these two up by changing...
|
by: deko |
last post by:
I'm wondering if anyone has come across something like this before and could
offer some suggestions.
I need to extract all the Single values packed in a Long Binary field (4k
chunks) and then...
|
by: aarklon |
last post by:
Hi folks,
I found an algorithm for calculating the day of the week here:-
http://www.faqs.org/faqs/calendars/faq/part1/index.html
in the section titled 2.5 what day of the week was 2 august...
|
by: tech101 |
last post by:
Can I get the master (or slaves) to automatically remove the binary
logs once they are processed by all slaves?
It says in the mysql manual :
If you are using replication, you should not delete...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |