%
if request.Form("lstDay")="" then
lstDay=1
else
lstDay=request.Form("lstDay")
end if
if request.Form("lstMonth")="" then
lstMonth=1
else
lstMonth=request.Form("lstMonth")
end if
if request.Form("lstYear")="" then
lstYear=2500
else
lstYear=Cint(request.Form("lstYear"))
end if
'--------------------------------------------------------------
'Global Variable
'option explicit
dim Age_in_Day
dim Age_in_Day2
dim Age_in_StartMonth
dim Age_in_StartMonth2
dim Curr_Start1 , Curr_Start2 , Curr_Start3
dim Curr2_Start1, Curr2_Start2, Curr2_Start3
dim Next_Start1, Next_Start2 , Next_Start3
dim Next2_Start1 , Next2_Start2 , Next2_Start3
dim lMonth, lYear
dim lMonth2 , lYear2 ,strPredict
'------------------------------------------------------
Function leapyear(Year)
'-----------------------------------------------------------------------------------------------
' ฟังก์ชันสำหรับ: คำนาณหาหาปีอธิกสุรทิน (leapyear)
' โดย : นาย สันติ ลิ้มพรชัยเจริญ
' วันที่ : ๒๕ พฤศจิกายน พ.ศ. ๒๕๔๑
' อินพุต : Year (พ.ศ.)
' เอาพุต : True or False , Leapyear = True
'-----------------------------------------------------------------------------------------------
If Year < 2484 Then
'กรณีที่ ปี พ.ศ. ก่อน ๒๔๘๓
If (Year - 542) Mod 100 = 0 Then
If (Year - 542) Mod 40 = 0 Then
leapyear = True
Else
leapyear = False
End If
ElseIf (Year - 542) Mod 4 = 0 Then
leapyear = True
Else
leapyear = False
End If
Else
'กรณีที่ ปี พ.ศ. ๒๔๘๔ เป็นต้นไป
If (Year - 543) Mod 100 = 0 Then
If (Year - 543) Mod 40 = 0 Then
leapyear = True
Else
leapyear = False
End If
ElseIf (Year - 543) Mod 4 = 0 Then
leapyear = True
Else
leapyear = False
End If
End If
End Function
Function DayofMonth()
dim lmonth
lMonth = month(Date)
Select Case lMonth
Case 1, 3, 5, 7, 8, 10, 12
DayofMonth = 31
Case 2
If LeapYear(lYear + 543) = True Then
DayofMonth = 29
Else
DayofMonth = 28
End If
Case 4, 6, 9, 11
DayofMonth = 30
End Select
End Function
Function Count_Day(strDay, strMonth, strYear)
Dim ValYear
Dim BirthDay , CurrentDay
Dim arrMonth(12)
arrMonth(1) = "Jan"
arrMonth(2) = "Feb"
arrMonth(3) = "Mar"
arrMonth(4) = "Apr"
arrMonth(5) = "May"
arrMonth(6) = "Jun"
arrMonth(7) = "Jul"
arrMonth(8) = "Aug"
arrMonth(9) = "Sep"
arrMonth(10) = "Oct"
arrMonth(11) = "Nov"
arrMonth(12) = "Dec"
'Change format month
Select Case strMonth
Case 1
strMonth = "Jan"
Case 2
strMonth = "Feb"
Case 3
strMonth = "Mar"
Case 4
strMonth = "Apr"
Case 5
strMonth = "May"
Case 6
strMonth = "Jun"
Case 7
strMonth = "Jul"
Case 8
strMonth = "Aug"
Case 9
strMonth = "Sep"
Case 10
strMonth = "Oct"
Case 11
strMonth = "Nov"
Case 12
strMonth = "Dec"
End Select
'Change Year
ValYear = Cint(strYear) - 543
strYear = ValYear
BirthDay = strDay & "-" & strMonth & "-" & strYear
If CInt(year(Now())) > 2400 Then
CurrentDay = CStr(day(Now())) & "-" & arrMonth(month(Now() - 1)) & "-" & CStr(year(Now()) - 543)
Else
CurrentDay = CStr(day(Now())) & "-" & arrMonth(month(Now() - 1)) & "-" & CStr(year(Now()))
End If
'CurrentDay = Now()
Count_Day = DateDiff("d", BirthDay, CurrentDay) + 1 'Add one day for end day
'Adjust to 1st of Month
'Count_Day = Count_Day - day(CurrentDay) + 1
Count_Day = Count_Day - day(CurrentDay)
End Function
'-------------------------------------------
'Predict
'-------------------------------------------
Function Predict(Curr_Start1,Curr_Start2,Curr_Start3)
Const Physical_cycle = 23
Const Sensitivity_Cycle = 28
Const Intellect_cycle = 33
Dim Start1(32), Start2(32), Start3(32)
Dim Endmonth, i, Stop_date
Dim temp_date,strPredict,strNext 'ของเดือนถัดไป
dim arrMonth,dtmDate,strYear
arrMonth = Array("มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", _
"กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม")
Endmonth = DayofMonth()
Start1(1) = Curr_Start1
Start2(1) = Curr_Start2
Start3(1) = Curr_Start3
'Reset txtPredict
'dtmDate=Now() + 0.471
dtmDate=Now()
if year(dtmDate) < 2400 then
strYear=year(dtmDate) + 543
end if
strPredict = "ผลการทำนายประจำเดือน " & arrMonth(month(dtmDate)-1) & " พ.ศ." & stryear & "
"
'-----------------------------------------------------------------------------------------------------------
'Predict
'--------------------------
'Predict Physical Cycle
'-------------------------
strPredict = strPredict & "สภาพร่างกาย" & " "
For i = 1 To Endmonth
'ระยะบวก 1-7
If Start1(i) = 1 Then
Stop_date = i + 6
If Stop_date > Endmonth Then
Stop_date = Stop_date - Endmonth
strNext = " ของเดือนถัดไป "
End If
strPredict = strPredict & "วันที่ " & i & " ถึงวันที่ " & Stop_date & strNext & " ในช่วงนี้คุณจะมีร่างกายที่แข็งแรง วันที่ " & Stop_date & " ร่างกายจะแข็งแรงมากที่สุด จึงเหมาะที่จะงานที่ใช้ออกกำลังกาย เช่นการลงแข่งขันกีฬาต่างๆ นักกีฬาหลายท่านได้เหรียญทองเมื่อทำการแข่งขันในช่วงนี้ แต่อย่าออกกกำลังมากเกินไปอาจทำให้บาดเจ็บหรือไม่สบายได้" & " "
strNext=""
End If
'วันวิกฤติ
'ระยะลบ 18-24
If Start1(i) = 18 Then
Stop_date = i + 6
If Stop_date > Endmonth Then
Stop_date = Stop_date - Endmonth
strNext = " ของเดือนถัดไป "
End If
strPredict = strPredict & "วันที่ " & i & " ถึงวันที่ " & Stop_date & strNext & " เป็นช่วงที่คุณเหนื่อยอ่อนเพลียมาก" + _
"ความสามารถอยู่ในระดับต่ำกว่ามาตราฐาน และอุบัติเหตุมักจะเกิดได้ในช่วงนี้ วันที่ " & i & " เป็นวันที่ร่างกายอ่อนแอมากที่สุด จึงควรระวังในช่วงนี้จะ และร่างกายไม่สมบูรณ์นักในช่วงนี้ อย่าทำอะไรอย่างประมาท" & " "
strNext=""
End If
'ระยะบวกที่ 2 25-30
If Start1(i) = 25 Then
Stop_date = i + 5
If Stop_date > Endmonth Then
Stop_date = Stop_date - Endmonth
strNext = " ของเดือนถัดไป "
End If
strPredict = strPredict & "วันที่ " & i & " ถึงวันที่ " & Stop_date & strNext & " ร่างกายคุณแข็งแรงมากที่สุดอีกช่วงหนึ่ง ดังนั้นจึงเหมาะกับงานที่ใช้กำลังกาย แต่อย่าออกกกำลังมากเกินไปเพราะอาจทำให้บาดเจ็บหรือไม่สบายได้" & " "
strNext=""
End If
Start1(i + 1) = Start1(i) + 1
If Start1(i + 1) > Physical_cycle Then Start1(i + 1) = 1
Next
'---------------------------------
'Predict Sensitivity Cycle
'----------------------------------
strPredict = strPredict & " " & "สภาวะทางอารมณ์" & " "
For i = 1 To Endmonth
'ระยะบวก
If Start2(i) = 1 Then
Stop_date = i + 13
If Stop_date > Endmonth Then
Stop_date = Stop_date - Endmonth
strNext = " ของเดือนถัดไป "
End If
strPredict = strPredict & "วันที่ " & i & " ถึงวันที่ " & Stop_date & strNext & " เป็นช่วงที่คุณมีอารมณ์แจ่มใส่ และมองโลกในแง่ดี " & " "
strNext=""
End If
If Start2(i) = 8 Then
strPredict = strPredict & "วันที่ " & i & " จิตใจสดชื่นแจ่มใสมากที่สุด และความสัมพันธ์กับคนรอบข้างเป็นไปด้วยดี เหมาะที่จะขอความรักเป็นที่สุด" & " "
End If
'วันวิกฤติ
If Start2(i) = 14 Or Start2(i) = 28 Then
strPredict = strPredict & "วันที่ " & i & " เป็นวันที่คุณจะอารมณ์แปรปรวนมากที่สุด ในระยะ 2-3 วันนี้คุณควรหลีกเลี่ยงการชับรถ ง่านรื่นเริงต่างๆ ถ้าหลีกเลี่ยงไม่ได้ก็ให้ระวังเป็นพิเศษ" & " "
End If
'ระยะลบ
If Start2(i) = 15 Then
Stop_date = i + 13
If Stop_date > Endmonth Then
Stop_date = Stop_date - Endmonth
strNext = " ของเดือนถัดไป "
End If
strPredict = strPredict & "วันที่ " & i & " ถึงวันที่ " & Stop_date & strNext & " เป็นช่วงที่คุณเกิดอารมณ์เสียง่าย โกรธง่าย ไม่ค่อยได้รับความร่วมมือจากคนทั่วไป" & " "
strNext=""
End If
If Start2(i) = 22 Then
strPredict = strPredict & "วันที่ " & i & " เป็นวันที่คุณมีอาการโกรธง่าย หรืออารมณ์เสียง่ายเกิดขึ้นมากที่สุด" & " "
End If
'-------------------------------------------------------------------------------------------------------------
Start2(i + 1) = Start2(i) + 1
If Start2(i + 1) > Sensitivity_Cycle Then Start2(i + 1) = 1
Next
'----------------------------------
'Predict Intellect Cycle
'---------------------------------
strPredict = strPredict & " " & "ความสามารถทางปัญญา" & " "
For i = 1 To Endmonth
'ระยะบวก
If Start3(i) = 1 Then
Stop_date = i + 15
If Stop_date > Endmonth Then
Stop_date = Stop_date - Endmonth
strNext = " ของเดือนถัดไป "
End If
strPredict = strPredict & "วันที่ " & i & " ถึงวันที่ " & Stop_date & strNext & " เป็นช่วงที่คุณมีความจำแม่น มีสมาธิ และมีความทะเยอทะยาน " & " "
strNext=""
End If
If Start3(i) = 8 Then
Stop_date = i + 1
If Stop_date > Endmonth Then
Stop_date = Stop_date - Endmonth
strNext = " ของเดือนถัดไป "
End If
strPredict = strPredict & "วันที่ " & i & " ถึงวันที่ " & Stop_date & strNext & " เป็นช่วงที่คุณมีสมองที่ดีเลิศ สามารถแก้ปัญหาต่างๆได้อย่างง่ายดาย " & " "
strNext=""
End If
'วันวิกฤติ
If Start3(i) = 17 Then
strPredict = strPredict & "วันที่ " & i & " เป็นวันที่สมองของคุณสับสน ยุ่งเหยิง ไม่เหมาะที่จะตัดสินใจเรื่องที่สำคัญ ควรรอผ่านวันนี้ไปก่อน 1-2 วัน ในระยะนี้คุณควรทำอะไรอย่างรอบคอบ" & " "
End If
'ระยะลบ
If Start3(i) = 18 Then
Stop_date = i + 15
If Stop_date > Endmonth Then
Stop_date = Stop_date - Endmonth
strNext = " ของเดือนถัดไป "
End If
strPredict = strPredict & "วันที่ " & i & " ถึงวันที่ " & Stop_date & strNext & " เป็นช่วงที่ความคิดของคุณจะช้าลง ความรับรู้ช้า " & " "
strNext=""
End If
'-----------------------------------------------------------------------------------------------------------------------
Start3(i + 1) = Start3(i) + 1
If Start3(i + 1) > Intellect_cycle Then Start3(i + 1) = 1
Next
'--------------------------------------------------------------------------------------------------------------
' หาวันวิกฤติ ที่สอดคล้องกันของทั้ง 3 วัฏจักร
For i = 1 To Endmonth
Dim strTreeCycle
strTreeCycle = ""
'Physical and sensitivity cycle
If (Start1(i) = 12 Or Start1(i) = 23) And (Start2(i) = 14 Or Start2(i) = 15 Or Start2(i) = 28) Then
strTreeCycle = strTreeCycle & "วันที่ " & i & " เป็นวันที่มีโอกาสเกิดอุบัติเหตุสูงสุด ควรหลีกเลี่ยงการขับรถ หรือสิ่งที่เสี่ยงต่อการเกิดอุบัติเหตุ ทำสิ่งต่างๆอย่างระมัดระวัง " & " "
End If
If Len(strTreeCycle) > 0 Then
strPredict = strPredict & "วันวิกฤติ ที่สอดคล้องกันของทั้ง 3 วัฏจักร" & " " & strTreeCycle
End If
Next
Predict=strPredict
End function
'---------------------------------------------------------------
if Request.Form("cmdPredict")<>"" then
'------------------------------------------------------------------------
Dim MaxDay,StrDay,StrMonth,StrYear,longDay
Dim longMonth,longYear
Dim Lunar
Dim TmpStr,Result
strDay = Cint(request("lstDay"))
strMonth = Cint(request("lstMonth"))
strYear = Cint(request("lstYear"))
'---------------------------------------------------------------------------------------------
'Plot Graph
Age_in_Day = Count_Day(strDay,strMonth,strYear)
Age_in_StartMonth = Age_in_Day
Curr_Start1 = Age_in_StartMonth Mod 23
Curr_Start2 = Age_in_StartMonth Mod 28
Curr_Start3 = Age_in_StartMonth Mod 33
If Curr_Start1 = 0 Then Curr_Start1 = 23
If Curr_Start2 = 0 Then Curr_Start2 = 28
If Curr_Start3 = 0 Then Curr_Start3 = 33
strPredict=Predict(Curr_Start1,Curr_Start2,Curr_Start3)
strGraph=""
'Response.Write strPredict
else
strGraph=""
end if%>