Fortune Telling Collection - Horoscope - How to write a program for calculating constellations in VB with relatively simple sentences and find out the detailed process?
How to write a program for calculating constellations in VB with relatively simple sentences and find out the detailed process?
As far as the current development is concerned, the readability and structure of programs (algorithms) are the mainstream requirements because of the rapid improvement of computer speed and storage space.
I once said that using one line of code to solve a problem, using 1000 lines of code (the example is extreme), has no effect on people's feelings when the computer is running.
There are many solutions to your problem. Of course, arrays and complex If statements will be used.
I'm using a method now. Would you please see if it is simple?
Add two combo boxes Combo 1 and Combo2, a button and a text box Text 1 to the form:
The code is as follows:
Option explicit
Private XZ in string form
Private subcommand 1_Click ()
Mark m as a string
Mark d as a string
Dim d 1 as the date
Mark d2 as a date
Mark l as an integer
M = Combo 1。 text
D = Combo2。 text
L = instrument (XZ, m)
If d < = mid (xz, l+3,3), then
Text 1。 Text = "Your constellation is"&; Mid(XZ,L - 3,3)
other
Text 1。 Text = "Your constellation is"&; Median value (XZ, l+6,3)
If ... it will be over.
End joint
Private Sub-Form _Load ()
Mark I as an integer
Combo 1。 clear
For i = 1 to 12.
If I < then 10
Combo 1。 Additem "0" & CSTR (I) and "Moon"
other
Combo 1。 Additional items CStr(i) and "Moon"
If ... it will be over.
Next, I
Combo 1。 Text = Combo 1。 List (0)
Combination 2. clear
For i = 1 to 3 1
If I < then 10
Combination 2. Additem "0" & CSTR (I) and "Day"
other
Combination 2. Additional items CStr(i) and "Day"
If ... it will be over.
Next, I
Combination 2. Text = Combo2。 List (0)
XZ = "Capricorn 065438+1October 20th Aquarius February 19 Pisces March 20th Aries April 20th Taurus May 2nd1Gemini June 2nd1Cancer"&; _
"July 22nd Leo August 23rd Virgo September 23rd Libra 65438+1October 23rd Scorpio 65438+/October 22nd Sagittarius 65438+February 2nd1Capricorn"
End joint
I didn't use arrays and complicated If statements in this program, but I used Instr () function, which was relatively unreadable.
At the same time, leap year and big month and small month have not been considered in February.
- Previous article:Give me some of Xu Zhimo's most beautiful articles
- Next article:Han constellation
- Related articles
- Twelve constellations exclusive butterfly girl _ Twelve constellations exclusive butterfly girl name
- A copy suitable for Aries, an inspirational quote for Aries.
- Did Li Xiaotian, played by Gao Ye in the hit drama Our Marriage, surprise everyone?
- What is the constellation on June 2nd?
- I don't like the constellation of coquetry and sympathy. I will conquer others with my strength and make people willingly submit.
- What does it mean to dream that the tent fell down?
- Like swans, they only guard each other's constellation pairing all their lives.
- Hand-painted illustration of twelve constellations, what constellation are you? "wallpaper background avatar"
- Do you know what the constellation of each other's life is before you fall in love?
- What is the psychology of people who believe in constellations?