Click here to Skip to main content
16,016,184 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionSqlHelper Class Pin
cst_cfit12-Mar-07 18:23
cst_cfit12-Mar-07 18:23 
QuestionData Grid Selection Pin
umesh896512-Mar-07 17:59
umesh896512-Mar-07 17:59 
QuestionApplication Slowdown Question Pin
tgebrael12-Mar-07 17:57
tgebrael12-Mar-07 17:57 
AnswerRe: Application Slowdown Question Pin
tgebrael12-Mar-07 18:01
tgebrael12-Mar-07 18:01 
AnswerRe: Application Slowdown Question Pin
TwoFaced12-Mar-07 18:52
TwoFaced12-Mar-07 18:52 
GeneralRe: Application Slowdown Question Pin
tgebrael12-Mar-07 21:47
tgebrael12-Mar-07 21:47 
QuestionNumber of sundays in a month.......... Pin
Member 387988112-Mar-07 17:50
Member 387988112-Mar-07 17:50 
AnswerRe: Number of sundays in a month.......... [modified] Pin
TwoFaced12-Mar-07 20:38
TwoFaced12-Mar-07 20:38 
The basic calculation is this. What you want to do is shift the calander so it starts on the day you are looking for. For instance if there are 31 days in the month and Sunday is the 3rd day then we'll throw out the first 2 days. This leaves us will 29 days (the first of which is sunday). If we divide 29 by 7 and round up, we end up with 5 which will be the number of Sundays in that month. Anyway, that's the principal behind this function I made. It takes 3 parameters. A Year and Month as well as the Day you are looking for. I used the DayOfWeek enum for the day parameter. 0 = Sunday, 1 = monday, ... 6 = saturday.
Private Function GetDaysInMonth(ByVal year As Integer, ByVal month As Integer, ByVal day As System.DayOfWeek) As Integer
    'Date object for the first day of the month
    Dim myDate As New Date(year, month, 1)

    'Number of Days from the start of the month until the day
    'we are looking for.
    Dim nextOccurance As Integer = day - myDate.DayOfWeek
    If nextOccurance < 0 Then nextOccurance += 7

    'Return number of occurances in month
    Return Math.Ceiling((Date.DaysInMonth(year, month) - nextOccurance) / 7)
End Function
To use the function:
'Sundays in march 2007
Dim occurences = GetDaysInMonth(2007, 3, DayOfWeek.Sunday)



-- modified at 2:54 Tuesday 13th March, 2007
GeneralRe: Number of sundays in a month.......... [modified] Pin
Member 387988112-Mar-07 23:29
Member 387988112-Mar-07 23:29 
GeneralRe: Number of sundays in a month.......... Pin
Member 387988112-Mar-07 23:54
Member 387988112-Mar-07 23:54 
Questiontrying to develop a program to run an .bat file as admin Pin
cpltek12-Mar-07 12:01
cpltek12-Mar-07 12:01 
AnswerRe: trying to develop a program to run an .bat file as admin Pin
Dave Kreskowiak12-Mar-07 12:45
mveDave Kreskowiak12-Mar-07 12:45 
GeneralRe: trying to develop a program to run an .bat file as admin Pin
cpltek13-Mar-07 3:05
cpltek13-Mar-07 3:05 
GeneralRe: trying to develop a program to run an .bat file as admin Pin
Dave Kreskowiak13-Mar-07 3:15
mveDave Kreskowiak13-Mar-07 3:15 
GeneralRe: trying to develop a program to run an .bat file as admin [modified] Pin
cpltek13-Mar-07 3:31
cpltek13-Mar-07 3:31 
GeneralRe: trying to develop a program to run an .bat file as admin Pin
cpltek13-Mar-07 3:38
cpltek13-Mar-07 3:38 
QuestionGet enter button command Pin
harveyhanson12-Mar-07 11:30
harveyhanson12-Mar-07 11:30 
AnswerRe: Get enter button command Pin
JUNEYT12-Mar-07 12:36
JUNEYT12-Mar-07 12:36 
GeneralRe: Get enter button command Pin
harveyhanson12-Mar-07 13:12
harveyhanson12-Mar-07 13:12 
GeneralRe: Get enter button command Pin
M-Hall12-Mar-07 14:44
M-Hall12-Mar-07 14:44 
GeneralRe: Get enter button command Pin
harveyhanson12-Mar-07 15:23
harveyhanson12-Mar-07 15:23 
QuestionCalling a windows application Pin
code123581312-Mar-07 10:47
code123581312-Mar-07 10:47 
AnswerRe: Calling a windows application Pin
M-Hall12-Mar-07 11:15
M-Hall12-Mar-07 11:15 
QuestionMy.Computer.Network.DownloadFile Pin
tgebrael12-Mar-07 10:46
tgebrael12-Mar-07 10:46 
AnswerRe: My.Computer.Network.DownloadFile Pin
Dave Kreskowiak12-Mar-07 12:37
mveDave Kreskowiak12-Mar-07 12:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.