473,378 Members | 1,447 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

How get the month values

I have got the return value of MonthsOfYear Property of the IMonthlyTrigger
Interface, but how to return months?
http://msdn2.microsoft.com/en-us/lib...36(VS.85).aspx

My return value is 84, it shuld be 3,5,7 month, but i do not know how to get
the three months using bitwise mask.

Regards
Steven

Mar 27 '08 #1
6 1300
On Mar 26, 9:01*pm, "Steven" <ga...@163.comwrote:
I have got the return value of MonthsOfYear Property of the IMonthlyTrigger
Interface, but how to return months?http://msdn2.microsoft.com/en-us/lib...36(VS.85).aspx

My return value is 84, it shuld be 3,5,7 month, but i do not know how to get
the three months using bitwise mask.

Regards
Steven
Steven - It's a bit mask.

Module Module1

<Flags()_
Enum Months
January = &H1
February = &H2
March = &H4
April = &H8
May = &H10
June = &H20
July = &H40
August = &H80
September = &H100
October = &H200
November = &H400
December = &H800
End Enum

Sub Main()
Dim m As Months = Months.March Or Months.May Or Months.July
Console.WriteLine(m)
End Sub

End Module

HTH,

--
Tom Shelton
Mar 27 '08 #2
yxq
Thank you, but i want to know how to get months from 84.

"Tom Shelton" <to*********@comcast.net写入消息
news:cf**********************************@u10g2000 prn.googlegroups.com...
On Mar 26, 9:01 pm, "Steven" <ga...@163.comwrote:
I have got the return value of MonthsOfYear Property of the
IMonthlyTrigger
Interface, but how to return
months?http://msdn2.microsoft.com/en-us/lib...36(VS.85).aspx

My return value is 84, it shuld be 3,5,7 month, but i do not know how to
get
the three months using bitwise mask.

Regards
Steven
Steven - It's a bit mask.

Module Module1

<Flags()_
Enum Months
January = &H1
February = &H2
March = &H4
April = &H8
May = &H10
June = &H20
July = &H40
August = &H80
September = &H100
October = &H200
November = &H400
December = &H800
End Enum

Sub Main()
Dim m As Months = Months.March Or Months.May Or Months.July
Console.WriteLine(m)
End Sub

End Module

HTH,

--
Tom Shelton

Mar 27 '08 #3
On Mar 27, 8:08*am, "yxq" <ga...@163.netwrote:
My problem likehttp://groups.google.com/group/microsoft.public.dotnet.languages.vb/b...

But this problem seem not be sloved!

Thank you

"Armin Zingler" <az.nos...@freenet.deдϢ:ud31Jm$jIHA.1... @TK2MSFTNGP05.phx.gbl...
"yxq" <ga...@163.comschrieb
Thank you, but i want to know how to get months from 84.
I thought bitwise operations are basic basics in EDP. :-)
Use the And operator to check for certain bits.
http://msdn2.microsoft.com/en-us/library/wz3k228a.aspx
http://msdn2.microsoft.com/en-us/library/2h9cz2eb.aspx
Armin- Hide quoted text -

- Show quoted text -
It was solved.... You use the And operator to test:

Option Strict On
Option Explicit On

Imports System.Text

Module Module1
<Flags()_
Enum Months
January = &H1
February = &H2
March = &H4
April = &H8
May = &H10
June = &H20
July = &H40
August = &H80
September = &H100
October = &H200
November = &H400
December = &H800
End Enum
Sub Main()
Dim m As Months = Months.March Or Months.May Or Months.July
PrintMonths(m)
End Sub

Sub PrintMonths(ByVal m As Months)
Dim values() As Integer =
CType([Enum].GetValues(GetType(Months)), Integer())
Dim buffer As StringBuilder = New StringBuilder()

For Each value As Integer In values
If CBool(m And value) Then
buffer.AppendFormat("{0},",
[Enum].GetName(GetType(Months), value))
End If
Next

buffer.Length = buffer.Length - 1
Console.WriteLine(buffer)
End Sub
End Module

HTH,

--
Tom Shelton
Mar 27 '08 #4
yxq
Ok, that works well, thank you very much.

"Tom Shelton" <to*********@comcast.net写入消息
news:2d**********************************@n58g2000 hsf.googlegroups.com...
On Mar 27, 8:08 am, "yxq" <ga...@163.netwrote:
My problem
likehttp://groups.google.com/group/microsoft.public.dotnet.languages.vb/b...

But this problem seem not be sloved!

Thank you

"Armin Zingler" <az.nos...@freenet.deдÈëÏûÏ¢ÐÂÎÅ:ud31 Jm$jIHA.1...@TK2MSFTNGP05.phx.gbl...
"yxq" <ga...@163.comschrieb
Thank you, but i want to know how to get months from 84.
I thought bitwise operations are basic basics in EDP. :-)
Use the And operator to check for certain bits.
http://msdn2.microsoft.com/en-us/library/wz3k228a.aspx
http://msdn2.microsoft.com/en-us/library/2h9cz2eb.aspx
Armin- Hide quoted text -

- Show quoted text -
It was solved.... You use the And operator to test:

Option Strict On
Option Explicit On

Imports System.Text

Module Module1
<Flags()_
Enum Months
January = &H1
February = &H2
March = &H4
April = &H8
May = &H10
June = &H20
July = &H40
August = &H80
September = &H100
October = &H200
November = &H400
December = &H800
End Enum
Sub Main()
Dim m As Months = Months.March Or Months.May Or Months.July
PrintMonths(m)
End Sub

Sub PrintMonths(ByVal m As Months)
Dim values() As Integer =
CType([Enum].GetValues(GetType(Months)), Integer())
Dim buffer As StringBuilder = New StringBuilder()

For Each value As Integer In values
If CBool(m And value) Then
buffer.AppendFormat("{0},",
[Enum].GetName(GetType(Months), value))
End If
Next

buffer.Length = buffer.Length - 1
Console.WriteLine(buffer)
End Sub
End Module

HTH,

--
Tom Shelton

Mar 28 '08 #5
yxq
Please view the MSDN page:
http://msdn2.microsoft.com/en-us/lib...35(VS.85).aspx

How to write the enum of days? the number(1,2... can not as variable?)

<Flags()_
Enum Months
1 = &H1
2 = &H2
3 = &H4
4 = &H8
5 = &H10
6 = &H20
7 = &H40
8 = &H80
9 = &H100
10 = &H200
11 = &H400
12 = &H800
...
End Enum
"Tom Shelton" <to*********@comcast.net写入消息
news:2d**********************************@n58g2000 hsf.googlegroups.com...
On Mar 27, 8:08 am, "yxq" <ga...@163.netwrote:
My problem
likehttp://groups.google.com/group/microsoft.public.dotnet.languages.vb/b...

But this problem seem not be sloved!

Thank you

"Armin Zingler" <az.nos...@freenet.deдÈëÏûÏ¢ÐÂÎÅ:ud31 Jm$jIHA.1...@TK2MSFTNGP05.phx.gbl...
"yxq" <ga...@163.comschrieb
Thank you, but i want to know how to get months from 84.
I thought bitwise operations are basic basics in EDP. :-)
Use the And operator to check for certain bits.
http://msdn2.microsoft.com/en-us/library/wz3k228a.aspx
http://msdn2.microsoft.com/en-us/library/2h9cz2eb.aspx
Armin- Hide quoted text -

- Show quoted text -
It was solved.... You use the And operator to test:

Option Strict On
Option Explicit On

Imports System.Text

Module Module1
<Flags()_
Enum Months
January = &H1
February = &H2
March = &H4
April = &H8
May = &H10
June = &H20
July = &H40
August = &H80
September = &H100
October = &H200
November = &H400
December = &H800
End Enum
Sub Main()
Dim m As Months = Months.March Or Months.May Or Months.July
PrintMonths(m)
End Sub

Sub PrintMonths(ByVal m As Months)
Dim values() As Integer =
CType([Enum].GetValues(GetType(Months)), Integer())
Dim buffer As StringBuilder = New StringBuilder()

For Each value As Integer In values
If CBool(m And value) Then
buffer.AppendFormat("{0},",
[Enum].GetName(GetType(Months), value))
End If
Next

buffer.Length = buffer.Length - 1
Console.WriteLine(buffer)
End Sub
End Module

HTH,

--
Tom Shelton

Mar 28 '08 #6
On Mar 27, 6:42*pm, "yxq" <ga...@163.comwrote:
Please view the MSDN page:http://msdn2.microsoft.com/en-us/lib...35(VS.85).aspx

How to write the enum of days? the number(1,2... can not as variable?)

* *<Flags()_
* * Enum Months
* * * * 1 = &H1
* * * * 2 = &H2
* * * * 3 = &H4
* * * * 4 = &H8
* * * * 5 = &H10
* * * * 6 = &H20
* * * * 7 = &H40
* * * * 8 = &H80
* * * * 9 = &H100
* * * * 10 = &H200
* * * * 11 = &H400
* * * * 12 = &H800
* * * * ...
* * End Enum

"Tom Shelton" <tom_shel...@comcast.net写入消息news:2d******* ***************************@n58g2000hsf.googlegrou ps.com...
On Mar 27, 8:08 am, "yxq" <ga...@163.netwrote:


My problem
likehttp://groups.google.com/group/microsoft.public.dotnet.languages.vb/b...
But this problem seem not be sloved!
Thank you
"Armin Zingler" <az.nos...@freenet.deдÈëÏûÏ¢ÐÂÎÅ:ud31 Jm$jIHA.1...@TK2MSFTNGP05.phx.gbl...
"yxq" <ga...@163.comschrieb
>Thank you, but i want to know how to get months from 84.
I thought bitwise operations are basic basics in EDP. :-)
Use the And operator to check for certain bits.
>http://msdn2.microsoft.com/en-us/library/wz3k228a.aspx
>http://msdn2.microsoft.com/en-us/library/2h9cz2eb.aspx
Armin- Hide quoted text -
- Show quoted text -

It was solved.... *You use the And operator to test:

Option Strict On
Option Explicit On

Imports System.Text

Module Module1
* * <Flags()_
* * Enum Months
* * * * January = &H1
* * * * February = &H2
* * * * March = &H4
* * * * April = &H8
* * * * May = &H10
* * * * June = &H20
* * * * July = &H40
* * * * August = &H80
* * * * September = &H100
* * * * October = &H200
* * * * November = &H400
* * * * December = &H800
* * End Enum

* * Sub Main()
* * * * Dim m As Months = Months.March Or Months.MayOr Months.July
* * * * PrintMonths(m)
* * End Sub

* * Sub PrintMonths(ByVal m As Months)
* * * * Dim values() As Integer =
CType([Enum].GetValues(GetType(Months)), Integer())
* * * * Dim buffer As StringBuilder = New StringBuilder()

* * * * For Each value As Integer In values
* * * * * * If CBool(m And value) Then
* * * * * * * * buffer.AppendFormat("{0},",
[Enum].GetName(GetType(Months), value))
* * * * * * End If
* * * * Next

* * * * buffer.Length = buffer.Length - 1
* * * * Console.WriteLine(buffer)
* * End Sub
End Module

HTH,

--
Tom Shelton- Hide quoted text -

- Show quoted text -
In my taskscheduler code I used:

[Flags()]
public enum DaysOfMonth
{
First = 0x1,
Second = 0x2,
Third = 0x4,
Fourth = 0x8,
Fifth = 0x10,
Sixth = 0x20,
Seventh = 0x40,
Eighth = 0x80,
Ninth = 0x100,
Tenth = 0x200,
Eleventh = 0x400,
Twelfth = 0x800,
Thirteenth = 0x1000,
Fourteenth = 0x2000,
Fifteenth = 0x4000,
Sixteenth = 0x8000,
Seventeenth = 0x10000,
Eighteenth = 0x20000,
Nineteenth = 0x40000,
Twentieth = 0x80000,
TwentyFirst = 0x100000,
TwentySecond = 0x200000,
TwentyThird = 0x400000,
TwentyFourth = 0x800000,
TwentyFifth = 0x1000000,
TwentySixth = 0x2000000,
TwentySeventh = 0x4000000,
TwentyEighth = 0x8000000,
TwentyNineth = 0x10000000,
Thirtieth = 0x20000000,
ThirtyFirst = 0x40000000,
}

That's c#, but the translation is pretty easy - 0x = &H in vb :)

--
Tom Shelton
Mar 28 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Thomas R. Hummel | last post by:
Hello all, I have been working with several databases here that are basically data marts. A lot of the entities have an attribute that is a particular year and month. For example, a financial...
20
by: Laguna | last post by:
Hi Gurus, I want to find the expiration date of stock options (3rd Friday of the month) for an any give month and year. I have tried a few tricks with the functions provided by the built-in...
6
by: Hasanain F. Esmail | last post by:
Hi all, I sincerly thank you all in advance for your help to solve this problem. I have been trying to find a solution to this problem for sometime now but have failed. I am working on a...
6
by: Laura Stout | last post by:
Please help! I've been spinning my wheels on this one! I am working on a database that tracks future project opportunities. For each opportunity, the data entered includes total project value and...
6
by: Tony Miller | last post by:
All I have an aggregate query using the function Month & Year on a datereceived field ie: TheYear: Year() TheMonth: Month() These are the group by fields to give me a Count on another field by...
34
by: prosoft | last post by:
When I use Dim myDTFI As DateTimeFormatInfo = New CultureInfo("he-IL", True).DateTimeFormat Dim strhmon1 As String = (myDTFI.GetMonthName(hmon1)) MsgBox(strhmon1) I get the local name of the...
6
by: Zeba | last post by:
Hi, I have a page with a calendar and two datalist items - one containing month values and the other, year values. Depending on the month/year value chosen ( in text/string format ) I should be...
6
by: Nkhosinathie | last post by:
hello guys,i've started with classes and i've been given this program below to program and also i will post the source code if you need it.this program reads as folllows. create a class called...
5
by: Mike | last post by:
I use c#, V2005 How I can get difference between two dates and get value in month(s) I had found some solutions but it is not exactly what I need. private static int...
0
by: marlberg | last post by:
Platform: Windows2000, WindowsXP, Windows Vista, etc Language: C#, ASP.NET Pre-compiled Libraries: Enterprise Library 3.0 full I have a requirement to implement in and display in C# and...
1
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.