01.
Dim
result
As
Integer
= 0
02.
Dim
iStr
As
String
=
String
.Empty
03.
04.
Dim
need2CountDay
As
DayOfWeek = DayOfWeek.Thursday
05.
06.
Dim
FromDate
As
New
Date
(2015, 1, 1)
07.
Dim
ToDate
As
New
Date
(2015, 1, 30)
08.
09.
Dim
startADay
As
DayOfWeek = FromDate.DayOfWeek
10.
11.
Dim
totalDayRange
As
Integer
= (ToDate - FromDate).TotalDays
12.
13.
14.
Dim
AdjustDay
As
Integer
= (7 + need2CountDay - startADay)
Mod
7
15.
Dim
oddDay
As
Integer
= totalDayRange
Mod
7
16.
17.
result = (totalDayRange) / 7
18.
Dim
AddWeek = IIf(oddDay > AdjustDay, 1, 0)
19.
result = result + AddWeek
20.
21.
Dim
cultureInfo =
New
CultureInfo(
"th-TH"
)
22.
Dim
dateTimeInfo = cultureInfo.DateTimeFormat
23.
24.
iStr =
String
.Format(
"วัน «{0}» ทั้งหมด จาก «{1}» ถึง «{2}» มี «{3}» วัน นะแจ๊ะ"
_
25.
, dateTimeInfo.GetDayName(need2CountDay) _
26.
, FromDate.ToString(
"ddd d/MMM/yy"
, cultureInfo) _
27.
, ToDate.ToString(
"ddd d/MMM/yy"
, cultureInfo), result.ToString())
28.
Response.Write(iStr)