如果出生日期输入格式为19861212这种格式的话、以1-3月为为春季,4-6月为夏季,7-9月为秋季!10-12月为冬季!用以下程式码:
Private Sub Form_Load()
Dim birth As String
Dim year As Integer
Dim month As Integer
Dim day As String
Dim old As Integer
Dim season As String
Dim sx As Integer
Dim fx As String
birth = Trim(Str(InputBox("请输入您的生日!格式为19741212")))
year = Val(Left(birth, 4))
month = Val(Mid(birth, 5, 2))
day = Right(birth, 2)
old = 2015 - year
Select Case month
Case Is <= 3
season = "春季"
Case Is <= 6
season = "夏季"
Case Is <= 9
season = "秋季"
Case Is <= 12
season = "冬季"
End Select
sx = (year - 2016) Mod 12
If sx < 0 Then
sx = sx + 12
End If
Select Case sx
Case 0
fx = "猴"
Case 1
fx = "鸡"
Case 2
fx = "狗"
Case 3
fx = "猪"
Case 4
fx = "鼠"
Case 5
fx = "牛"
Case 6
fx = "虎"
Case 7
fx = "兔"
Case 8
fx = "龙"
Case 9
fx = "蛇"
Case 10
fx = "马"
Case 11
fx = "羊"
End Select
MsgBox "您的年龄为:" & old & vbCrLf & "您的出生季节为:" & season & vbCrLf & "您的属相为:" & fx
End Sub
我也就是閒着无聊?给这5分都不够敲键盘的
,
如果出生日期输入格式为19861212这种格式的话、以1-3月8865为春季!4-6月为夏季!7-9月为秋季!10-12月为冬季。用以下代码:
Private Sub Form_Load()
Dim birth As String
Dim year As Integer
Dim month As Integer
Dim day As String
Dim old As Integer
Dim season As String
Dim sx As Integer
Dim fx As String
birth = Trim(Str(InputBox("请输入您的生日,格式为19741212")))
year = Val(Left(birth, 4))
month = Val(Mid(birth, 5, 2))
day = Right(birth, 2)
old = 2015 - year
Select Case month
Case Is <= 3
season = "春季"
Case Is <= 6
season = "夏季"
Case Is <= 9
season = "秋季"
Case Is <= 12
season = "冬季"
End Select
sx = (year - 2016) Mod 12
If sx < 0 Then
sx = sx + 12
End If
Select Case sx
Case 0
fx = "猴"
Case 1
fx = "鸡"
Case 2
fx = "狗"
Case 3
fx = "猪"
Case 4
fx = "鼠"
Case 5
fx = "牛"
Case 6
fx = "虎"
Case 7
fx = "兔"
Case 8
fx = "龙"
Case 9
fx = "蛇"
Case 10
fx = "马"
Case 11
fx = "羊"
End Select
MsgBox "您的年龄为:" & old & vbCrLf & "您的出生季节为:" & season & vbCrLf & "您的属相为:" & fx
End Sub
我也就是闲着无聊!给这5分都不够敲键盘的!