'Below is a lunar calendar algorithm for VB
'Date data definition method is as follows
'The first 12 bytes represent from 1 to December for the day or Xiaoyue, 1 for the day of the month, 0 is 29 days in the month,
The 13th place is the month of the month, 1 is 30 days in the day, 0 is 29 days in Xiaoyue, and the 14th is the month of the month.
'Series, if it is not the month is 0, otherwise give the month, 10, 11, 12, a, b, and c
'Shows, even if you are billed. The last 4 is the new year of the Lunar New Year, the Lunar New Year, January 1, China
'Date, such as 0131 represents January 31.
'Getyldate functions The following way is the year that Tyear is to enter, TMONTH is the month, tday is
'Date, Ylyear is the return value, returns the year of the lunar calendar, such as the year, YLShuxing returns
'Is an image, such as a mouse. Isgetgl is the setup is the gauge value through the lunar calendar, if yes,
'The top three returned the corresponding question date, and the return value is a reply date.
Function GetYldate (Tyear As Integer, TMONTH AS INTEGER, TDAY AS INTEGER, _
Ylyear as string, ylshuxing as string, _
Optional isgetgl as boolean) AS STRING
ON Error ResMe next
DIM Dalist (1900 to 2011) AS String * 18
DIM CONDATE AS DATE, SETDATE AS DATE
Dim AddMonth As Integer, AddDay As Integer, Addyear AS Integer, Getday As Integer
DIM Runyue as Boolean
If Tyear> 2010 or Tyear <1901 Then EXIT FUNCTION 'If not valid, exit
'1900 to 1909
Dalist (1900) = "010010110110180131"
Dalist (1901) = "010010101110000219"
Dalist (1902) = "101001010111000208"
Dalist (1903) = "010100100110150129"
Dalist (1904) = "110100100110000216"
Dalist (1905) = "110110010101000204"
Dalist (1906) = "011010101010140125"
Dalist (1907) = "010101101010000213"
Dalist (1908) = "100110101101000202"
Dalist (1909) = "010010101110120122"
Dalist (1910) = "010010101110000210"
Dalist (1911) = "101001001101160130"
Dalist (1912) = "101001001101000218"
Dalist (1913) = "110100100101000206"
Dalist (1914) = "110101010100150126"
Dalist (1915) = "101101010101000214"
Dalist (1916) = "010101101010000204"
Dalist (1917) = "100101101101020123"
Dalist (1918) = "100101011011000211"
Dalist (1919) = "010010011011170201"
Dalist (1920) = "010010011011000220"
Dalist (1921) = "101001001011000208"
Dalist (1922) = "101100100101150128"
Dalist (1923) = "011010100101000216"
Dalist (1924) = "011011010100000205"
Dalist (1925) = "101011011010140124"
Dalist (1926) = "00101010110110000213"
Dalist (1927) = "100101010111000202"
Dalist (1928) = "010010010111120123"
Dalist (1929) = "010010010111000210"
Dalist (1930) = "011001001011060130"
Dalist (1931) = "110101001010000217"
Dalist (1932) = "111010100101000206"
Dalist (1933) = "011011010100150126"
Dalist (1934) = "010110101101000214"
Dalist (1935) = "001010110110000204"
Dalist (1936) = "100100110111030124"
Dalist (1937) = "100100101110000211"
Dalist (1938) = "110010010110170131"
Dalist (1939) = "110010010101000219"
Dalist (1940) = "110101001010000208"
Dalist (1941) = "110110100101060127"
Dalist (1942) = "101101010101000215"
Dalist (1943) = "010101101010000205"
Dalist (1944) = "101010101101140125"
Dalist (1945) = "001001011101000213"
Dalist (1946) = "100100101101000202"
Dalist (1947) = "110010010101120122"
Dalist (1948) = "101010010101000210"
Dalist (1949) = "101101001010170129"
Dalist (1950) = "011011001010000217" DALIST (1951) = "101101010101000206"
Dalist (1952) = "010101011010150127"
Dalist (1953) = "010011011010000214"
Dalist (1954) = "101001011011000203"
Dalist (1955) = "010100101011130124"
Dalist (1956) = "010100101011000212"
Dalist (1957) = "101010010101080131"
Dalist (1958) = "111010010101000218"
Dalist (1959) = "01101010101010000208"
Dalist (1960) = "101011010101060128"
Dalist (1961) = "101010110101000215"
Dalist (1962) = "010010110110000205"
Dalist (1963) = "101001010111040125"
Dalist (1964) = "101001010111000213"
Dalist (1965) = "010100100110000202"
Dalist (1966) = "111010010011030121"
Dalist (1967) = "110110010101000209"
Dalist (1968) = "010110101010170130"
Dalist (1969) = "010101101010000217"
Dalist (1970) = "100101101101000206"
Dalist (1971) = "010010101110150127"
Dalist (1972) = "010010101101000215"
Dalist (1973) = "101001001101000203"
Dalist (1974) = "110100100110140123"
Dalist (1975) = "110100100101000211"
Dalist (1976) = "110101010010180131"
Dalist (1977) = "101101010100000218"
Dalist (1978) = "101101101010000207"
Dalist (1979) = "100101101101060128"
Dalist (1980) = "100101011011000216"
Dalist (1981) = "010010011011000205"
Dalist (1982) = "101001001011140125"
Dalist (1983) = "101001001011000213"
Dalist (1984) = "1011001001011A0202"
Dalist (1985) = "011010100101000220" DALIST (1986) = "011011010100000209"
Dalist (1987) = "101011011010060129"
Dalist (1988) = "101010110110000217"
Dalist (1989) = "100100110111000206"
Dalist (1990) = "010010010111150127"
Dalist (1991) = "010010010111000215"
Dalist (1992) = "011001001011000204"
Dalist (1993) = "011010100101030123"
DALIST (1994) = "111010100101000210"
Dalist (1995) = "011010110010180131"
Dalist (1996) = "010110101100000219"
Dalist (1997) = "101010110110000207"
Dalist (1998) = "100100110110150128"
Dalist (1999) = "100100101110000216"
Dalist (2000) = "110010010110000205"
DALIST (2001) = "110101001010140124"
Dalist (2002) = "110101001010000212"
Dalist (2003) = "110110100101000201"
Dalist (2004) = "010110101010120122"
Dalist (2005) = "010101101010000209"
Dalist (2006) = "101010101101170129"
Dalist (2007) = "001001011101000218"
Dalist (2008) = "100100101101000207"
Dalist (2009) = "110010010101150126"
Dalist (2010) = "101010010101000214"
Dalist (2011) = "101101001010000214"
AddYear = Tyear
Runyue = false
If isgetgl then
AddMonth = VAL (MID (Dalist (AddYear), 15, 2))
Addday = VAL (MID (Dalist (AddYear), 17, 2))
Condate = dateserial (addyear, addmonth, addday)
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 (setdate)
TMONTH = MONTH (SetDate)
TDAY = day (setdate)
EXIT FUNCTION
END IF
Chushihua:
AddMonth = VAL (MID (Dalist (AddYear), 15, 2))
Addday = VAL (MID (Dalist (AddYear), 17, 2))
Condate = dateserial (addyear, addmonth, addday)
Setdate = dateserial (Tyear, TMONTH, TDAY)
Getday = datediff ("d", condate, setdate)
IF getday <0 Then adyear = addyar - 1: goto chushihua
'AddDay = NEARDAY
AddDay = 1: addmonth = 1
For i = 1 to getday
Addday = addday 1
IF addday = 30 mid (Dalist (addyear), Addmonth, 1) or (Runyue and AddDay = 30 MID (Dalist (AddYear), 13, 1))
IF Runyue = false and addmonth = VAL ("& H" & MID (Dalist (AddYear), 14, 1))
Runyue = TRUE
Else
Runyue = false
Addmonth = Addmonth 1
END IF
Addday = 1
END IF
NEXT
MD $ = "The first third day of the third day, the first six first seventh day, the first nine, the first year, 112233141四 五 五 六 廿 八
DD $ = MID (MD $, (AddDay - 1) * 2 1, 2)
MM $ = MID ("Zhengsi Tie Thirty or 567899 Tolden", AddMonth, 1) "Month"
Yougetdate = dateserial (addyear, addmonth, addday)
Tiangan $ = "Betten Britten" has Geng Xinyi "
Dizhi $ = "Zi ugly 寅 辰 巳 午 未 亥"
Dim Ganzhi (0 to 59) AS String * 2
FOR i = 0 to 59
Ganzhi (i) = MID (Tiangan $, (i MOD 10) 1, 1) MID (Dizhi $, (i MOD 12) 1, 1)
'ff $ = ff $ GANZHI (i)
Next I
'MSGBOX FF $,, LEN (ff $)
Ylyear = Ganzhi ((ADDYEAR - 4) MOD 60)
Shu $ = "Rat Niuhu Rabbit Dragon Snake Pigher Wool Monkey Chicken Dog"
Ylshuxing = MID (Shu $, (AdDyear - 4) MOD 12) 1, 1)
IF Runyue Then MM $ = "" mm $
GetYldate = mm $ DD $
END FUNCTION
'The following is an example of use, you need to add a button on the form, and name Command1, then copy the following code to the form of the form.
Private submmand1_click ()
DIM TY AS INTEGER, TM AS INTEGER, TD AS INTEGER, YL AS STRING, SX AS STRING
'Lunar Date of Taking the Queen of the Calendar 1999
TY = 1999
TM = 10
TD = 28
T = getYldate (TY, TM, TD, YL, SX)
Msgbox T
Msgbox Ty & "-" & TM & "-" & TD & "& YL &" & SX
'Take the Date of the Guan calendar of the Lunar New Year's Day in 1999
T = getYldate (TY, TM, TD, YL, SX, TRUE)
Msgbox T
Msgbox Ty & "-" & TM & "-" & TD & "& YL &" & SX
End Sub