VB根据生日计算星座
已知生日,格式如下1994-2-56,1987-10-88,1547-7-7,后面的数字位数不确定,怎样根据日期算出星座,要全部代码...
已知生日,格式如下1994-2-56,1987-10-88,1547-7-7,后面的数字位数不确定,怎样根据日期算出星座,要全部代码
展开
1个回答
展开全部
'建立一个command1控件,一个text1控件 Option Explicit Function Constellation(ByVal m As Date) As String '返回星座 Dim Number As Long Number = Month(m) * 100 + Day(m) Select Case Number Case 321 To 419 Constellation = "白羊" Case 420 To 520 Constellation = "金牛" Case 521 To 621 Constellation = "双子" Case 622 To 722 Constellation = "巨蟹" Case 723 To 822 Constellation = "狮子" Case 823 To 922 Constellation = "处女" Case 923 To 1023 Constellation = "天秤" Case 1024 To 1121 Constellation = "天蝎" Case 1122 To 1221 Constellation = "射手" Case 1222 To 1231 Constellation = "摩蝎" Case 101 To 119 Constellation = "摩蝎" Case 120 To 218 Constellation = "水瓶" Case 219 To 320 Constellation = "双鱼" Case Else Constellation = "无此星座!" End Select End Function Private Sub Command1_Click() If IsDate(Trim(Text1)) = True Then MsgBox Constellation(Trim(Text1)) Else MsgBox "日期格式错误!" End If End Sub Private Sub Form_Load() Command1.Caption = "星座" Text1 = "1547-7-7" End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询