|
-
Dec 19th, 2003, 12:35 PM
#1
Thread Starter
Hyperactive Member
Date Calculations & Stuff
I am working on a time entry form to interface with an existing accounting package. I need help with a particular calculation.
The week ending date for a payroll is always on a Saturday, which the program treats as day #7. I have 7 text boxes (Mon - Sun) for entering the time for each day on my form and I have to calculate the date the day falls on as well as the day number.
I have a few questions to help me get started:
[list=1][*]Is there a way to make sure a date entered into a text box is always a Saturday? In VBA I could use this If Not IsSaturday(WeekEnding) Then[*]Are there built in intrinsic day numbers? For instance does VB.net treat Monday as a 1 (or whatever number it may be?)[/list=1]
-
Dec 19th, 2003, 01:04 PM
#2
Frenzied Member
Are you looking for something like this:
VB Code:
Dim tToday As Date = Now.Date
If tToday.DayOfWeek.ToString = "Friday" Then
~Peter

-
Dec 19th, 2003, 01:11 PM
#3
Sleep mode
Re: Date Calculations & Stuff
For 1st question , You can use this little method (this is the only way I can think of now .)
VB Code:
Private Sub TodayIS()
Dim dt As New DateTime
Dim DayNumber As Integer
DayNumber = dt.Today.DayOfWeek
Select Case DayNumber
Case 0
MessageBox.Show("IT'S Sunday")
Case 1
MessageBox.Show("IT'S Monday")
Case 2
MessageBox.Show("IT'S Tuesday")
Case 3
MessageBox.Show("IT'S Wednesday")
Case 4
MessageBox.Show("IT'S Thursday")
Case 5
MessageBox.Show("IT'S Friday")
Case 6
MessageBox.Show("IT'S Saturday")
End Select
End Sub
For 2nd question , this is from MSDN Help :
The DayOfWeek enumeration represents the day of the week in calendars that have seven days per week. This enumeration ranges from zero, indicating Sunday, to six, indicating Saturday.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|