晨曦制作
答案:
Dim a(10) As Integer Dim b(10) As Integer Dim c(10) As Integer Private Sub Command1_Click()
Open App.Path & \For Input As #1 Open App.Path & \For Input As #2
For i = 0 To 9 Input #1, a(i) Input #2, b(i)
Next Close #1, #2
End Sub
Private Sub find(x() As Integer, t As Control)
Dim i As Integer, max As Integer
max = x(1) For i = 2 To 10
If max < x(i) Then max = x(i)
Next i t.Text = max End Sub
Private Sub Command2_Click()
Dim i As Integer For i = 1 To 10 c(i) = a(i) + b(i)
Next i
Open App.Path & \For Output As #1
For i = 0 To 9 Print #1, c(i)
Next Close #1 End Sub
Private Sub Command3_Click()
Call find(a, Text1) Call find(c, Text2)
Open App.Path & \For Output As #1
Print #1, Text1.Text, Text2.Text
Close #1 End Sub
第 11 页 共 13
页
晨曦制作
编写适当的事件过程,使程序运行后,可以使图像框闪烁,其闪烁速度可以通过滚动条来调节。
提示:图像框的闪烁可以通过图像框交替地显示和隐藏来实现。 要求:程序中不得使用变量,每个事件过程中只能写一条语句。
注意:存盘时必须存放在考生文件夹中,工程文件名为“sit2.vbp”,窗体文件名为“sjt2.frm”。
解答:
Private Sub HScroll1_Scroll() Timer1.Interval = HScroll1.Value
End Sub
Private Sub Timer1_Timer() Image1.Visible = Not Image1.Visible
End Sub
第 12 页 共 13
页
晨曦制作 题目:在名为Form1的窗体上绘制两个图像框,名称分别为Pic1和Pic2,宽度和高度均为1500,通过属性窗口把图像文件tp1.jpg放入Pic1中,把图像文件tp2.jpg放入Pic2中;再绘制一个名为Cmd1的命令按钮,标题为\图片交换\,如图1-4所示。编写适当的事件过程,使得在运行时,如果单击窗体,则交换
两个图像框中的图像。注意不允许使用第三个图像框。
Private Sub Form_Click() Dim pic As Object Set pic = Image1.Picture Image1.Picture = Image2.Picture
Image2.Picture = pic
End Sub
第 13 页 共 13
页