Fortune Telling Collection - Zodiac Analysis - Write judging constellations by date of birth in EXCEL with VB language!
Write judging constellations by date of birth in EXCEL with VB language!
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
- Related articles
- What magic does the zodiac have?
- What is the constellation of Junyan Jiao? A detailed analysis of Junyan Jiao constellation
- Love flattery, it is easy to photograph the constellation on the horseshoe.
- The heroine of the French film Rainbow
- What constellation is September 25th?
- A constellation that is easy to say the wrong thing.
- Shenzhen Constellation Legend Building _ Shenzhen Constellation Legend Building Address
- See what color the 12 constellation is suitable for dyeing hair.
- A constellation that is easy to humble when in love.
- How are constellations formed _ How are constellations formed? How many constellations are there?