Fortune Telling Collection - Free divination - Writing constellation pairing program code with vb

Writing constellation pairing program code with vb

Simple is relative. If less code is needed, readability and structure may be poor; Otherwise, the readability and structure may be better and the code may increase.

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:

Options? specific

Private? XZ? As? line

Private? Sub? Command 1_Click()

Dim? m? As? line

Dim? d? As? line

Dim? d 1? As? date

Dim? d2? As? date

Dim? l? As? integer

m? =? Combo 1。 text

d? =? Combination 2. text

l? =? Instrument (XZ, m)

What if? d? & lt=? Mid(XZ,? l? +? 3,? 3)? then

Text 1。 Words? =? What sign are you in? & amp? Mid(XZ,? l? -? 3,? 3)

other

Text 1。 Words? =? What sign are you in? & amp? Mid(XZ,? l? +? 6,? 3)

End? if

End? submarine

Private? Sub? Form_Load()

Dim? Me? As? integer

Combo 1。 clear

For what? Me? =? 1? Where to? 12

What if? Me? & lt? 10? then

Combo 1。 AddItem? "0"? & amp? CStr (1)? & amp? "the moon"

other

Combo 1。 AddItem? CStr (1)? & amp? "the moon"

End? if

Next? I

Combo 1。 Words? =? Combo 1。 List (0)

Combination 2. clear

For what? Me? =? 1? Where to? 3 1

What if? Me? & lt? 10? then

Combination 2. AddItem? "0"? & amp? CStr (1)? & amp? "day"

other

Combination 2. AddItem? CStr (1)? & amp? "day"

End? if

Next? iCombo2。 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.