VB 用数组完成 输入一个年份 输出这一年的属相。
展开全部
Private Sub Command1_Click()
Dim ArrShengxiao() As String
ArrShengxiao = Split("鼠、牛、虎、兔、龙、蛇、马、羊、猴、鸡、狗、猪", "、")
Dim Year As String
strYear = InputBox("请输入年份", "输入", "2014")
If Len(strYear) < 1 Then
MsgBox ("年份必须输入")
Exit Sub
End If
If IsNumeric(strYear) = False Then
MsgBox ("年份必须为数字")
Exit Sub
End If
'年生肖
Dim CurShengxiao As String
CurShengxiao = ArrShengxiao(Abs(((2014 - CInt(strYear)) Mod 12) - 6))
MsgBox strYear & "年生肖是:" & CurShengxiao
End Sub
展开全部
Private Sub Command1_Click()
Dim shuxiang()
Dim a As Integer
shuxiang = Array("猴", "鸡", "狗", "猪", "鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊")
a = Val(InputBox("请输入", "请输入年份"))
If a < 0 Then
a = (a Mod 12 + 12) Mod 12
Else
a = a Mod 12
End If
Print shuxiang(a)
End Sub
Dim shuxiang()
Dim a As Integer
shuxiang = Array("猴", "鸡", "狗", "猪", "鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊")
a = Val(InputBox("请输入", "请输入年份"))
If a < 0 Then
a = (a Mod 12 + 12) Mod 12
Else
a = a Mod 12
End If
Print shuxiang(a)
End Sub
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询