This is driving me towards lunacy :mad:
How can I get the week number from a datetime type ?
Any Ideas ?
There must be a nice simple, refined way to do this.
TIA
Printable View
This is driving me towards lunacy :mad:
How can I get the week number from a datetime type ?
Any Ideas ?
There must be a nice simple, refined way to do this.
TIA
Quote:
Originally Posted by venerable bede
VB Code:
Imports System.Globalization '... Dim myCI As New CultureInfo("en-US") 'defines the calendar system. Dim myCal As Calendar = myCI.Calendar messagebox.show(myCal.GetWeekOfYear(Date.Today, CalendarWeekRule.FirstFullWeek, DayOfWeek.Monday))
Dolly Dimple :thumb:
If I helped you rate me, if I didn't then don't :D
Thanks Wossy but I already tried that from the MSDN but I keep getting the error :
Calendar is ambiguous, imported from the namespaces or types, ' System.Globalization, System.UI.WebControls'
and before you say it, I have imported the Globalization namespace at the top of my page.
This doodles my dingo :confused:
OK, well fully qualify the class names then...
VB Code:
Dim myCI As New System.Globalization.CultureInfo("en-US") 'defines the calendar system. Dim myCal As System.Globalization.Calendar = myCI.Calendar messagebox.show(myCal.GetWeekOfYear(date.today, System.Globalization.CalendarWeekRule.FirstFullWeek, DayOfWeek.Monday))
Ambiguous names can be solved by fully qualifying the namespace explicitly.
Any Idea why you have to qualify the namespace explicitly ?
Strange.
Anyways, thnx wossy.
I'm glad I am carrying your baby. :)
Its not strange really its just that 2 namespaces (both of which you have imported in yout app) both have a class called Calendar. Its like someone saying "I'm flying to Aberdeen". The compiler thinks: "Which one? The one in Scotland or the one in America?" So you have to say it longhand: "I'm flying to Scotland.Aberdeen".Quote:
Originally Posted by venerable bede
Its perfectly legal to have 2 classes with the same name as long as they are in different namespaces. This is also possible if one namespace CONTAINS the other namespace (nested). A long as you qualify it then there is no problem.
NOTE: If there is a name conflict and the namespace is really long then you can do this:
VB Code:
Imports Woss = System.Drawing.Drawing2D
The word "Woss" then becomes a shorthand way of writing that long namespace :D Cool eh?
Then use the 'alias' to make life easier...
VB Code:
Dim gr as Woss.Graphics 'this is equivalent to... Dim gr as System.Drawing.Drawing2D.Graphics
PS, I can think of no better mother for my children. I hope its twins.