Fortune Telling Collection - Zodiac Analysis - How to Use Functions in Constellation Table _ How to Use Functions to Calculate Constellation Table
How to Use Functions in Constellation Table _ How to Use Functions to Calculate Constellation Table
In fact, the simplest idea should be to remove the year information of birthdays (such as A 1) (all unified as 1900, use the function date(0, month(A 1), day(A 1)), and then divide the dates with constellations (such as Aquarius/kloc). In the past, many online sentences used this idea to look up constellations.
But this method has a hidden bug: leap year. The constellation division day of leap year will increase by 1 after March. Hidden bugs are taboo! If someone calls your function, there will always be irregular errors. Sometimes you can't find the problem because your function has this hidden bug.
In order to bypass the bug of leap year, I wrote the following function, directly imitating the process of human flesh querying the month and day.
Of course, there are also some places that can be optimized. For example, the array of months can be directly optimized because the dimensions and contents are the same; For example, the final if statement structure can be replaced by iif statement. But these are the details. In order to better reflect the programming ideas, we will not do these "clever" optimizations.
Constellation function in string form (X stands for date)
Dim XZ( 12) as a string.
Dim Yue( 12) as the length
Dim Ri( 12) As Long
XZ(0) = "Capricorn"
XZ( 1) = "Aquarius"
XZ(2) = "Pisces"
XZ(3) = "Aries"
XZ(4) = "Taurus"
XZ(5) = "Gemini"
XZ(6) = "cancer"
XZ(7) = "Leo"
XZ(8) = "Virgo"
XZ(9) = "Libra"
XZ( 10) = "Scorpio"
XZ( 1 1) = "Sagittarius"
XZ( 12) = "Capricorn"
Yue (1) = 1
Yue (2) = 2
Yue (3) = 3
Yue (4) = 4
Yue (5) = 5
Yue (6) = 6
Yue (7) = 7
Yue (8) = 8
Yue (9) = 9
Yue (10) = 10
Yue (11) =11
Yue (12) = 12
Ri( 1) = 20
Ri(2) = 19
Ri(3) = 2 1
Ri(4) = 20
Ri(5) = 2 1
Ri(6) = 22
Ri(7) = 23
Ri(8) = 23
Ri(9) = 23
Ri( 10) = 24
Ri( 1 1) = 23
Ri( 12) = 22
M = month (x)
D = days (x)
If d< day (day (meter)) and then
Horoscope = XZ (Yue (m)-1)
other
Horoscope = XZ (month (meter))
If ... it will be over.
End function
- Previous article:Do you know which constellations are often angry because of stress?
- Next article:What constellation is Pan Jinlian in modern terms?
- Related articles
- The biggest obstacle on the road to love is being too impulsive. Which constellation is it?
- 1995 lunar calendar 10 October 1 1 What is the date of the child's birthday in the solar calendar, and what constellation is it?
- How to test the friends of the zodiac _ How to test the friends of the zodiac
- What constellations are there that have no patience and reason and will never talk nonsense if they can do it?
- Which constellation has the heaviest heart _ which constellation has the thinnest center of gravity?
- 1988 February 12 What is the constellation? What kind of personality do you belong to?
- Future Outlook of Crystal Constellation _ Future Outlook Forecast of Crystal Constellation
- This week, the price of constellation 12 is short _ 12 is short.
- Am I Scorpio or Sagittarius?
- What is the constellation always calculated based on _ What is the constellation always calculated based on?