资源描述
1给定年份和月份,判断该年是否是闰年。并根据给出的月份判断是什么季节、该月有多少天。(闰年的条件是:年份能被4整除但不能被100整除或能被400整除)Private Sub Command1_Click()Dim x As Integer, y As IntegerText1.Text = InputBox(请输入年份 )x = Val(Text1.Text)Text3.Text = (x Mod 4) = 0 And (x Mod 100 0) _Or (x Mod 4) = 0 And (x Mod 400 = 0)End SubPrivate Sub Command2_Click()Dim x As Integer, y As IntegerText2.Text = InputBox(请输入月份)y = Val(Text2.Text)Select Case yCase 3 To 5Text4.Text = 春季 Case 6 To 8Text4.Text = 夏季Case 9 To 11Text4.Text = 秋季Case 1, 2, 12Text4.Text = 冬季End SelectEnd SubPrivate Sub Command3_Click()Dim x As Integer, y As IntegerText1.Text = InputBox(请输入年份)x = Val(Text1.Text)Text3.Text = (x Mod 4) = 0 And (x Mod 100 0) _Or (x Mod 4) = 0 And (x Mod 400 = 0)Text2.Text = InputBox(请输入月份)y = Val(Text2.Text)Select Case yCase 1, 3, 5, 7, 8, 10, 11Text5.Text = 31天Case 4, 6, 9, 12Text5.Text = 30天Case 2If Text1.Text = 0 ThenText5.Text = 29天ElseText5.Text = 28天End IfEnd SelectEnd Sub2编写程序,输入学生的姓名、学号和成绩(高数、英语和专业课),判断该学生能获得几等奖学金,并输出结果。获奖条件是:一等奖学金要求所有成绩在95分以上;二等奖学金要求所有成绩在90分以上;三等奖学金要求所有成绩在88分以上。Private Sub Command1_Click() Dim m%, n%, d%, sun%, no$, name$ no = InputBox(输入学号) name = InputBox(输入姓名) m = Val(Text1.Text) n = Val(Text2.Text) d = Val(Text3.Text) sun = m + n + d If m 95 And n 95 And d 95 Then Label5.Caption = name & 获一等奖学金 ElseIf m = 90 And n = 90 And d = 90 Then Label5.Caption = name & 获二等奖学金 ElseIf m = 88 And n = 88 And d = 88 Then Label5.Caption = name & 获三等奖学金 Else Label5.Caption = name & 没有奖学金 End If End Sub Private Sub Command2_Click() Text1.Text = Text2.Text = Text3.Text = Label5.Caption = End Sub 3编写一个程序输入某人的身高(cm)和体重(kg),按下式确定其体重是否为标准、过胖或过瘦:(1)标准体重=身高-110;(2)超过标准体重5kg为过胖;(3)低于标准体重5kg为过瘦。Private Sub Command1_Click()Dim m!, n%, d!m = Val(Text1.Text)n = Val(Text2.Text)d = n - 110Label5.Caption = 按你的身高,标准体重为: & d & 公斤If m - d 5 ThenLabel6.Caption = 你比较胖,请注意瘦身ElseIf m = d ThenLabel6.Caption = 你是标准体重ElseLabel6.Caption = 你比较瘦,请注意锻炼End IfEnd SubPrivate Sub Command2_Click()Text1.Text = Text2.Text = Label5.Caption = Label6.Caption = End SubPrivate Sub Command3_Click()EndEnd Sub4征兵的条件是:男性(sex)年龄(age)在1820之间,身高(size)在1.65米以上;或者女性(sex)年龄(age)在1618之间,身高(size)在1.60米以上。用三个文本框控件分别输入性别、年龄、身高信息,根据这些信息判断是否符合征兵条件,用标签控件输出结果。Private Sub Command1_Click()Dim m$, n%, d!m = Text1.Textn = Val(Text2.Text)d = Val(Text3.Text)If m = 男 And n = 18 And n 1.63 ThenLabel5.Caption = 符合征兵条件ElseIf m = 女 And n = 16 And n 1.6 ThenLabel5.Caption = 符合征兵条件ElseLabel5.Caption = 不符合征兵条件End IfEnd SubPrivate Sub Command2_Click()EndEnd Sub5为某航空公司设计一售机票程序,能根据月份和订票数决定优惠率,计算票价。假设优惠折扣规定如下:在旅游的旺季79月份,如果订票数超过20张,票价优惠15%;20张以下,票价优惠5%。在旅游的淡季15月份、10月份和11月份,如果订票数超过20张,票价优惠30%,20张以下,票价优惠20%。其他情况,一律优惠20%。Private Sub Command1_Click()Dim m%, n%, r%, dj!m = Val(Text1.Text)n = Val(Text2.Text)dj = Val(Text3.Text)Select Case mCase 1 To 5If n = 20 Then r = 20 Else r = 30Case 7 To 9If n = 20 Then r = 5 Else r = 15Case Elser = 20End SelectLabel4.Caption = 所订机票的优惠率为: & Str(r) & %Label6.Caption = 单张票价为 & (100 - r) * dj / 100 & 元 & ,共收款 & (100 - r) * dj * n / 100 & 元End SubPrivate Sub Command2_Click()EndEnd SubPrivate Sub Form_Load()Text1.Text = Month(Date)End Sub6利用if语句求三个数x,y,z中的最大值,并将其放入Max变量中显示输出。Private Sub Command1_Click()i = Val(Text1.Text)j = Val(Text2.Text)k = Val(Text3.Text)m = iIf (i j) Then m = jIf (m = 285 And m 90 And n 90 And d 90 ThenLabel5.Caption = 可以免费旅游颐和园?故宫和天坛ElseIf m = 88 And n = 88 And d = 88 ThenLabel5.Caption = 可以免费旅游颐和园?故宫ElseIf m = 80 And n = 80 And d = 80 ThenLabel5.Caption = 可以免费旅游颐和园ElseLabel5.Caption = 不可以免费旅游End IfEnd SubPrivate Sub Command2_Click()Text1.Text = Text2.Text = Text3.Text = Label5.Caption = End SubPrivate Sub Command3_Click()EndEnd Sub9在“神州号”程序中,需要判断飞船飞行状况。当飞船速度继续加大时,飞船将达到第二宇宙、第三宇宙速度(见下表)试编写程序,输入不同的飞船速度V,判断它的各种飞行状况,显示出来。飞船速度( V) 单位(km/s)飞行状况 7.91=V11.19 飞船绕地球做匀速圆周运动 11.19=V16.67 飞船挣脱太阳引力飞出太阳系 Private Sub Command1_Click()Dim v!v = Val(Text1.Text)If (v 7.91 And v = 11.19 And v = 16.67) ThenText2.Text = 飞船挣脱太阳引力飞出太阳系 End If End SubPrivate Sub Command2_Click()EndEnd Sub10编一段程序,从键盘输入3个整数,找出其中绝对值最小的数。Private Sub Command1_Click()i = Val(Text1.Text)j = Val(Text2.Text)k = Val(Text3.Text)m = Abs(i)If (m Abs(j) Then m = Abs(j)If (m Abs(k) Then m = Abs(k)Text4.Text = mEnd SubPrivate Sub Command3_Click()EndEnd Sub
展开阅读全文