Private Sub Command1_Click()
Dim str1 As String, d1 As Date, i As Integer, xz
xz = Array("白羊座", 3, 21, 4, 20, "金牛座", 4, 21, 5, 20, "双子座", 5, 21, 6, 21, _
"巨蟹座", 6, 22, 7, 22, "狮子座", 7, 23, 8, 22, "处女座", 8, 23, 9, 22, _
"天秤座", 9, 23, 10, 22, "天蝎座", 10, 23, 11, 21, "射手座", 11, 22, 12, 21, _
"摩羯座", 12, 22, 12, 31, "摩羯座", 1, 1, 1, 19, "水瓶座", 1, 20, 2, 18, _
"双鱼座", 2, 19, 3, 20)
str1 = txtMonth & "-" & txtDay
If IsDate(str1) Then
'd1 = CDate(str1)
For i = 0 To UBound(xz) Step 5
If Val(txtMonth) >= xz(i + 1) And Val(txtDay) >= xz(i + 2) _
And Val(txtMonth) <= xz(i + 3) And Val(txtDay) <= xz(i + 4) Then
MsgBox "你查询的" & str1 & "的星座" & xz(i), vbOKOnly, "星座查询"
Exit For
End If
Next i
Else
MsgBox "你输入的数据" & str1 & "不是日期!", vbOKOnly, "星座查询"
End If
End Sub |