How get the month values

T

Tom Shelton

I have got the return value of MonthsOfYear Property of the IMonthlyTrigger
Interface, but how to return months?http://msdn2.microsoft.com/en-us/library/aa380736(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,
 
Y

yxq

Thank you, but i want to know how to get months from 84.

"Tom Shelton" <[email protected]> 写入消æ¯
I have got the return value of MonthsOfYear Property of the
IMonthlyTrigger
Interface, but how to return
months?http://msdn2.microsoft.com/en-us/library/aa380736(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,
 
Y

yxq

Thank you, but i yet do not know how to analyze the value 84 to months ,
could you please tell me the codes...
 
T

Tom Shelton

My problem likehttp://groups.google.com/group/microsoft.public.dotnet.languages.vb/b...

But this problem seem not be sloved!

Thank you

"Armin Zingler" <[email protected]> дÈëÏûÏ¢ÐÂÎÅ:[email protected]...






- 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,
 
Y

yxq

Ok, that works well, thank you very much.

"Tom Shelton" <[email protected]> 写入消æ¯
My problem
likehttp://groups.google.com/group/microsoft.public.dotnet.languages.vb/b...

But this problem seem not be sloved!

Thank you

"Armin Zingler" <[email protected]> ôÈëÃûâÃÂÎÅ:[email protected]...






- 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,
 
Y

yxq

Please view the MSDN page:
http://msdn2.microsoft.com/en-us/library/aa380735(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" <[email protected]> 写入消æ¯
My problem
likehttp://groups.google.com/group/microsoft.public.dotnet.languages.vb/b...

But this problem seem not be sloved!

Thank you

"Armin Zingler" <[email protected]> ôÈëÃûâÃÂÎÅ:[email protected]...






- 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,
 
T

Tom Shelton

Please view the MSDN page:http://msdn2.microsoft.com/en-us/library/aa380735(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" <[email protected]> 写入消æ¯
My problem
likehttp://groups.google.com/group/microsoft.public.dotnet.languages.vb/b...
But this problem seem not be sloved!
Thank you
"Armin Zingler" <[email protected]> ôÈëÃûâÃÂÎÅ:[email protected]...
- 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,

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 :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top