Private Sub Form_Load() Picture1.Height = 3200 Picture1.Width = 0 Picture1.Left = 0 Picture1.Top = 0 HScroll1.Max = 5900 HScroll1.Min = 0 HScroll1.Value = 0 End Sub Private Sub HScroll1_Change() Picture1.Width = HScroll1.Value End Sub
Private Sub Command1_Click() Dim s As String, c As String * 1 s = Text1.Text For i = 1 To Len(s) c = Mid(s, i, 1) If c >= \ Text2.Text = Text2.Text & \ Else Text2.Text = Text2.Text & c End If Next i End Sub 第十套
一、程序启动运行后,图片框PictureBox1不可见,在定时器控制下,图片沿垂直方向以较慢的速度自动展开,到图片完全展开时,定时器停止工作(初始条件在窗体加载事件过程中设置,图片自选)。
二、在文本框1中输入一串字符,分别统计其中大写字母和小写字母的个数,结果显示在文本框2中。
三、程序功能是用随机函数产生20个3位整数,再找出其中大于平均值的数
以每行5个的格式输出。 Private Sub Form_Click()
Dim a(1 To 30) As Integer, n As Integer
Dim ave As Integer, sum As Single 'Dim ave As Single Randomize
For i = 1 To 20 '产生20个数据并输出
a(i) = Int(Rnd * 900 + 100):Print a(i); sum = sum + a(i) Next i
Print:ave = ave / 20 '计算平均值 ' sum
Print \大于平均值的数是:\For i = 1 To 20
If a(i) > ave Then '寻找大于平均值的数
n = n + 1:Print a(i) ' Print a(i);
If n \\ 5 = 0 Then Print '按每行5个输出大于平均值的数 'mod Next k ' End If Next i End Sub 一、参考程序 二、参考程序 Private Sub Form_Load() Picture1.Width = 5900 Picture1.Height = 0 Timer1.Interval = 100 Timer1.Enabled = True End Sub Private Sub Timer1_Timer() If Picture1.Height < 3200 Then Picture1.Height = Picture1.Height + 20 Else Timer1.Enabled = False End If End Sub
Private Sub Command1_Click() Dim n1 As Integer, n2 As Integer s = Text1.Text For i = 1 To Len(s) c = Mid(s, i, 1) If c >= \ n1 = n1 + 1 ElseIf c >= \ n2 = n2 + 1 End If Next i Text2.Text = \大写字符数=\& vbCrLf & \小写字符数:\End Sub 第十一套
一、设计所示界面的程序,程序运行后,输入球的半径,单击\球体积\、\球
表面积\复选框,根据复选框是否勾选,决定是否在右侧相应的文本框内显示球体积?R3和球表面积4?R2的计算值。(40分)
二、程序运行后,在\起始值\和\结束值\两个文本框中分别输入一个整数(大小不限),单击\计算累加和\按钮,就能在文本框下方的Label控件中显示起始值与结束值之间所有奇数的累加和。
三、学生成绩数据已经保存在数组a中,学生姓名已经保存在数组b中,单击窗体,就能在窗体上显示成绩最好的学生姓名及其成绩。(30分) Private Sub Form_Click()
Dim a As Variant, b As String a = Array(85, 77, 92, 66, 44)
43
b = Array(\黄玉梅\朱明霞\孙家宝\赵天明\杨百万\ Max = a(0): student = b(0) For i = 1 To 5
If b(i) > Max Then
Max = a(i): student = b(i) End If Next i
Print \成绩最好的学生是:\考试成绩为:\分\End Sub
Private Sub Check2_Click()
r = Val(Text1.Text) 第一题参考代码 If Check2.Value = 1 Then Private Sub Check1_Click() v = 4 * 3.14159 * r ^ 2 r = Val(Text1.Text) Text3.Text = v If Check1.Value = 1 Then Else v = 4 * 3.14159 * r ^ 3 / 3 Text3.Text = \ Text2.Text = v End If Else End Sub Text2.Text = \ End If End Sub
第二题参考代码:
Private Sub Command1_Click()
X1 = Val(Text1.Text):X2 = Val(Text2.Text):Sum = 0 If X1 < X2 Then n = 1 Else n = -1 For i = X1 To X2 Step n If i Mod 2 <> 0 Then Sum = Sum + i End If Next i
Label3.Caption = \从\到\之间所有奇数的累加和=\End Sub
第三题参考答案:
Private Sub Form_Click()
Dim a As Variant, b As Variant a = Array(85, 77, 92, 66, 44)
b = Array(\黄玉梅\朱明霞\孙家宝\赵天明\杨百万\ Max = a(0):student = b(0) For i = 1 To 4
If a(i) > Max Then
Max = a(i):student = b(i) End If Next i
Print \成绩最好的学生是:\考试成绩为:\分\End Sub
3.程序的功能是:10个评委的评分数据已经保存在数组a中,单击窗体,就能去掉一个最高分,去掉一个最低分,然后计算平均值,作为参赛选手的实际
得分,并在窗体上输出。(30分) Private Sub Command1_Click() Dim score As Variant
score = Array(93.88, 91.77, 92.66, 94.55, 90.99, 96.11, 97.22, 99.01, 98, 93.33)
Max = score(0) For i = 1 To 10
:Min = score(0):Sum = 0 If score(i) > Max Then Max = score(i) If score(i) < Min Then Min = score(i) Sum = Sum + score(i) Next i
average = (Sum - Max - Min) / 10
Print \End Sub
参赛选手的实际得分:\第三题参考答案:
Private Sub Command1_Click() Dim score As Variant
score = Array(93.88, 91.77, 92.66, 94.55, 90.99, 96.11, 97.22, 99.01, 98, 93.33)
Max = score(0):Min = score(0):Sum = score(0) For i = 1 To 9
If score(i) > Max Then Max = score(i) If score(i) < Min Then Min = score(i) Sum = Sum + score(i) Next i
average = (Sum - Max - Min) / 8 Print \参赛选手的实际得分:\End Sub