Calculation method of VB lunar calendar
The basic calculation method is provided, supplemented by specific applications.
Date data is defined as follows
The first 12 bytes indicate that 1- 12 is a big month or a small month, 1 is a big month with 30 days, and 0 is a small month with 29 days.
13 is a leap month, 1 is a big month with 30 days, 0 is a small month with 29 days, and 14 is a leap month.
If it is not a leap month, it is 0; otherwise, the month is given. 10, 1 1 2 are denoted by a, b and c respectively.
, that is, using 16 radix. The last four digits are the Gregorian calendar where the Lunar New Year is located-that is, the 1 day of the lunar calendar.
For example, 0 13 1 stands for 65438+1October 3 1.
The usage of the "GetYLDate" function is as follows: tYear is the year to be entered, tMonth is the month, and tDay is.
Date, YLyear is the return value, and the year of the lunar calendar is added back, such as the year of Jiazi, and YLShuXing returns.
It's an elephant, like a mouse. IsGetGl is to set whether to take the Gregorian calendar value through the lunar calendar. If so,
The first three return the corresponding Gregorian date, and the return value is a Gregorian date.
The function GetYLDate(tYear is an integer, tMonth is an integer, tDay is an integer, _
YLyear is a string, YLShuXing is a string, _
Optional IsGetGl is boolean) as a string.
Continue to the next step when an error occurs.
Dim daList( 1900 to 20 1 1) as String * 18.
Dim conDate is the date, and setDate is the date.
Dim AddMonth is an integer, AddDay is an integer, AddYear is an integer, and getDay is an integer.
Dim runyue is boolean.
If tYear & gt20 10 or TYEAR <1901then exit the function' if it is invalid and has a date, exit.
1900 to 1909
daList( 1900)= " 0 100 1 10 1 10 180 13 1 "
daList( 190 1)= " 0 10 10 1 1 1 100002 19 "
daList( 1902)= " 10 10 10 10 1 1 1 1000208 "
daList( 1903)= " 0 10 100 1 10 10 150 129 "
daList( 1904)= " 1 100 100 1 1 100002 16 "
daList( 1905)= " 1 1 100 10 10 10 1000204 "
daList( 1906)= " 0 1 10 10 10 10 10 140 125 "
daList( 1907)= " 0 10 1 10 10 10 100002 13 "
daList( 1908)= " 100 10 10 1 1 10 1000202 "
daList( 1909)= " 0 100 10 1 1 1 10 120 122 "
daList( 19 10)= " 0 10 10 1 1 1 100002 10 "
daList( 19 1 1)= " 100 100 1 10 1 1 1 160 130 "
daList( 19 12)= " 10 100 1 10 10002 18 "
daList( 19 13)= " 1 100 100 10 10 1000206 "
daList( 19 14)= " 1 10 10 10 10 10 150 126 "
daList( 19 15)= " 10 10 10 10 10 10002 14 "
daList( 19 16)= " 0 10 1 10 10 10 10000204 "
daList( 19 17)= " 100 10 10 1 10 10 1020 123 "
daList( 19 18)= " 100 10 1 10 1 10002 1 1 "
daList( 19 19)= " 0 100 1 10 1 1 1 17020 1 "
daList( 1920)= " 0 100 100 10 1 1 1000220 "
daList( 192 1)= " 10 100 100 10 1 1000208 "
daList( 1922)= " 10 100 100 10 1 1 150 128 "
daList( 1923)= " 0 1 10 100 10 10002 16 "
daList( 1924)= " 0 1 1 10 10 10 10000205 "
daList( 1925)= " 10 1 10 1 10 10 10 140 124 "
daList( 1926)= " 00 10 1 10 1 1 100002 13 "
daList( 1927)= " 100 10 10 1 1 1 1 1000202 "
daList( 1928)= " 0 100 10 1 1 1 1 1 120 123 "
daList( 1929)= " 0 100 10 1 1 1 10002 10 "
daList( 1930)= " 0 1 100 10 1 1 1060 130 "
daList( 193 1)= " 1 10 100 10 100002 17 "
daList( 1932)= " 1 10 10 100 10 10 1000206 "
daList( 1933)= " 0 1 1 10 10 10 10 150 126 "
daList( 1934)= " 0 10 10 10 1 10 10 10002 14 "
daList( 1935)= " 00 10 10 10 1 1 10000204 "
daList( 1936)= " 100 100 10 1 1 1 1030 124 "
daList( 1937)= " 100 10 1 1 100002 1 1 "
daList( 1938)= " 1 100 10 1 10 10 170 13 1 "
daList( 1939)= " 1 100 10 10 10 10002 19 "
daList( 1940)= " 1 10 100 10 10 10000208 "
daList( 194 1)= " 1 1 10 10 10 10 1060 127 "
daList( 1942)= " 10 10 10 10 10 10 10002 15 "
daList( 1943)= " 0 10 1 10 10 10 10000205 "
daList( 1944)= " 10 10 10 1 10 1 1 1 140 125 "
daList( 1945)= " 00 100 10 1 10 10002 13 "
daList( 1946)= " 100 100 10 1 10 1000202 "
daList( 1947)= " 1 100 10 10 1 1 120 122 "
daList( 1948)= " 10 100 10 10 10 10002 10 "
daList( 1949)= " 10 10 100 10 10 10 170 129 "
daList( 1950)= " 0 1 1 100 10 100002 17 "
daList( 195 1)= " 10 10 10 10 10 10 10 100206 "
daList( 1952)= " 0 10 10 1 10 10 10 150 127 "
daList( 1953)= " 0 100 10 1 10 100002 14 "
daList( 1954)= " 10 10 1 10 10 1 1 1000203 "
daList( 1955)= " 0 10 10 10 1 1 1 1 130 124 "
daList( 1956)= " 0 10 10 10 1 1 10002 12 "
daList( 1957)= " 10 100 10 10 1080 13 1 "
daList( 1958)= " 1 10 100 10 10 10 10002 18 "
daList( 1959)= " 0 1 10 10 10 10 10000208 "
daList( 1960)= " 10 1 10 10 10 10 1060 128 "
daList( 196 1)= " 10 10 1 10 10 10 10002 15 "
daList( 1962)= " 0 100 10 10 1 1 10000205 "
daList( 1963)= " 10 10 10 1 1 1 1040 125 "
daList( 1964)= " 10 10 10 1 1 1 10002 13 "
daList( 1965)= " 0 10 100 100 1 10000202 "
daList( 1966)= " 1 10 100 100 1 1030 12 1 "
daList( 1967)= " 1 1 100 10 10 10 1000209 "
daList( 1968)= " 0 10 10 10 10 10 10 170 130 "
daList( 1969)= " 0 10 1 10 10 10 100002 17 "
daList( 1970)= " 100 10 10 1 1 10 1000206 "
daList( 197 1)= " 0 10 10 1 1 1 10 150 127 "
daList( 1972)= " 0 100 10 1 10 10 10002 15 "
daList( 1973)= " 10 100 100 1 10 1000203 "
daList( 1974)= " 1 100 100 1 10 10 140 123 "
daList( 1975)= " 1 100 100 10 10002 1 1 "
daList( 1976)= " 1 10 10 100 10 180 13 1 "
daList( 1977)= " 10 10 10 10 100002 18 "
daList( 1978)= " 10 10 1 10 10 10 10000207 "
daList( 1979)= " 100 10 10 1 10 10 1060 128 "
daList( 1980)= " 100 10 1 10 1 1 10002 16 "
daList( 198 1)= " 0 100 1 10 1 1 1 1000205 "
daList( 1982)= " 10 100 10 1 1 1 1 140 125 "
daList( 1983)= " 10 100 10 1 1 10002 13 "
daList( 1984)= " 10 100 100 10 1 1 1 1a 0202 "
daList( 1985)= " 0 1 10 100 10 10 1000220 "
daList( 1986)= " 0 1 1 10 10 10 10000209 "
daList( 1987)= " 10 1 10 1 10 10 10060 129 "
daList( 1988)= " 10 10 1 10 1 1 100002 17 "
daList( 1989)= " 100 100 10 1 1 1 1 1000206 "
daList( 1990)= " 0 100 10 1 1 1 1 1 150 127 "
daList( 199 1)= " 0 100 10 1 1 1 10002 15 "
daList( 1992)= " 0 1 100 100 10 1 1000204 "
daList( 1993)= " 0 1 10 100 10 10 1030 123 "
daList( 1994)= " 1 10 10 100 10 10002 10 "
daList( 1995)= " 0 1 10 1 100 10 180 13 1 "
daList( 1996)= " 0 10 10 10 1 1 100002 19 "
daList( 1997)= " 10 10 1 10 1 1 1 10000207 "
daList( 1998)= " 100 100 10 1 10 10 150 128 "
daList( 1999)= " 100 10 1 1 1 100002 16 "
Da Park Jung Su people (2000) = "11001011000205".
daList(200 1)= " 1 10 100 10 10 10 140 124 "
daList(2002)= " 1 10 10 100 10 10002 12 "
daList(2003)= " 1 10 10 100 10 10 100020 1 "
daList(2004)= " 0 10 1 10 10 10 10 120 122 "
DaList(2005) = "0101010101000209"
DaList(2006) = "10101110170.
daList(2007)= " 00 100 10 1 1 10 10002 18 "
daList(2008)= " 100 100 10 1 10 10 1000207 "
daList(2009)= " 1 100 100 10 10 1 150 126 "
daList(20 10)= " 10 100 10 10 10 10002 14 "
daList(20 1 1)= " 10 10 100 10 100002 14 "
AddYear = tYear
Runyue = false
If IsGetGl, then
add month = Val(Mid(daList(AddYear), 15,2))
AddDay = Val(Mid(daList(AddYear), 17,2))
ConDate = DateSerial (add year, add month, add day)
AddDay = tDay
For i = 1 to tMonth-1
AddDay = AddDay+29+Val(Mid(daList(tYear),I, 1))
Next, I
MsgBox DateDiff("d ",conDate,Date)
setDate = DateAdd("d ",AddDay - 1,conDate)
GetYLDate = setDate
TYear = Year (set date)
TMonth = month (set date)
TDay = day (set date)
Exit function
If ... it will be over.
Chu Shihua:
add month = Val(Mid(daList(AddYear), 15,2))
AddDay = Val(Mid(daList(AddYear), 17,2))
ConDate = DateSerial (add year, add month, add day)
setDate = DateSerial(tYear,tMonth,tDay)
getDay = DateDiff("d ",conDate,setDate)
If getDay & lt0 Then add year = add year- 1:GoTo Chu Shihua
addday = NearDay
add day = 1:add month = 1
For i = 1
Date of addition = date of addition+1
If AddDay = 30+Mid(daList(AddYear), AddMonth, 1) or (RunYue and AddDay = 30+Mid(daList(AddYear), 13, 1)), then
If RunYue = False,add month = Val(& amp; H "& ampMid(daList(AddYear), 14, 1)) and then.
Runyue = truth
other
Runyue = false
AddMonth = AddMonth + 1
If ... it will be over.
AddDay = 1
If ... it will be over.
then
Md$ = "Grade 1, Grade 2, Grade 3, Grade 4, Grade 5, Grade 6, Grade 7, Grade 8, Grade 9, Grade 11, Grade 12, Grade 34, Grade 56, Grade 789, Grade 21, Grade 22, Grade 23, Grade 24, Grade 26, Grade 27, Grade 28, Grade 29 and Grade 30"
dd$ = Mid(md$,(AddDay - 1) * 2 + 1,2)
Mm$ = Mid ("Zheng 234567890 cold wax", AddMonth, 1)+ "month"
YouGetDate = DateSerial (add year, add month, add day)
Tiangan $ = "A, B, C, D, E, G, G, G"
Dizhi$ = "Zi Chou Mao Yinchen has applied for a visit at noon."
Dim ganzhi(0 to 59) as the string * 2.
For i = 0 to 59
Trunk branch (i) = Mid (heavenly stem $,(i Mod 10)+1)+mid (earthly branch $,(i Mod 12)+1
Franc = Franc+Branches (1)
Next, I
MsgBox francs, loans (francs)
YLyear = ganzhi((AddYear - 4) Mod 60)
Shu $ = "mouse, cow, tiger, rabbit, dragon, snake, horse, sheep, monkey, chicken, dog, pig"
YLShuXing = Mid(shu$,((AddYear - 4) Mod 12) + 1, 1)
Mm$ = "leap" +mm$ if the moon is moist.
GetYLDate = mm$ + dd$。
End function
The following is an example of use. You need to add a button to the form, name it Command 1, and then copy the following code into the code of the form.
Private subcommand 1_Click ()
Dim ty is an integer, tm is an integer, td is an integer, yl is a string, and sx is a string.
Take the Gregorian calendar lunar date1999101October 28th.
ty = 1999
tm = 10
td = 28
t = GetYLDate(ty,tm,td,yl,sx)
MsgBox t
MsgBox ty & amp“-”& amp; tm & amp“-”& amp; td & amp”& ampyl & amp”& ampsx
Take the Gregorian calendar date1October 28th, 1999.
t = GetYLDate(ty,tm,td,yl,sx,True)
MsgBox t
MsgBox ty & amp“-”& amp; tm & amp“-”& amp; td & amp”& ampyl & amp”& ampsx
End joint