注册 登录
编程论坛 VB6论坛

求助,不知道哪出问题了!

xiaoqing2014 发布于 2014-04-26 16:20, 370 次点击
问题编写一个可以查询某人属相的程序(提示:1900年出生的人属“鼠”)
 程序:
Dim Year As Integer
 Dim Name As Integer
 Year = Val(InputBox("请输人出生年份:", "生肖查询", 1900))
 Label1.Caption = "您是" & Str(Year) + "年出生的生肖为:"
 Name = Year Mod 12
 Select Case Name  
 Case 4     
 Label2.Caption = "鼠"  
 Case 5   
 Label2.Caption = "牛"   
 Case 6     
 Label2.Caption = "虎"   
 Case 7     
 Label2.Caption = "兔"   
 Case 8     
 Label2.Caption = "龙"   
 Case 9     
 Label2.Caption = "蛇"  
 Case 10     
 Label2.Caption = "马"   
 Case 11     
 Label2.Caption = "羊"   
 Case 0     
 Label2.Caption = "猴"   
 Case 1     
 Label2.Caption = "鸡"   
 Case 2     
 Label2.Caption = "狗"   
 Case 3     
 Label2.Caption = "猪"
 End Select
以上是我自个儿编的,可运行的时候好像不对,求高手帮忙,不知是哪错了!
3 回复
#2
风吹过b2014-04-26 16:40
看代码是没错。对应关系对了吗?
#3
lowxiong2014-04-26 17:10
经测试没什么问题,不过用下述代码更简洁
Dim Year As Integer
Dim Name As Integer
Year = Val(InputBox("请输人出生年份:", "生肖查询", 1900))
Label1.Caption = "您是" & Str(Year) + "年出生的生肖为:"
Name = (Year Mod 12) + 1
Label2.Caption = Mid("猴鸡狗猪鼠牛虎兔龙蛇马羊", Name, 1)
#4
xiaoqing20142014-04-27 13:30
谢谢!我自己又查了一下,是我自己在输入的时候出错了!呵呵。。。。
1