内容发布更新时间 : 2024/11/15 13:42:23星期一 下面是文章的全部内容请认真阅读。
图3
Private Sub Command1_Click() Dim s1 As String, s2 As String s1 = s2 =
For i = (10)
s3 = s3 + Mid(s1, i, 1) + Mid(s2, i, 1) Next i s3 End Sub
10.下列程序的功能是将数组中的奇数相加。给定的程序不完整,将程序补充完整。
Option Base 1
Private Sub form_Click() Dim k As Integer Dim Total As Integer Dim n
n = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) For k = 1 To UBound(n) If (11) Then Total = Total + n(k) End If Next k Print Total End Sub
11.窗体上有三个文本框Text1控件数组,两个按钮Command1和Command2,一个图片框Pic1。程序功能是解一个一元
2二次方程(ax?bx?c?0)。程序运行后如图4所示。给定的程序不完整,将程序补充完整。
图4
Private Sub Command1_Click()
Dim a As Single, b As Single, c As Single Dim x1 As Single, x2 As Single Dim st As Single a = Val(Text1(0).Text) b = Val(Text1(1).Text) c = Val(Text1(2).Text) If a <> 0 Then col = (12) st = -b / (2 * a) If (13) Then
x1 = st + Sqr(col) / (2 * a) x2 = st - Sqr(col) / (2 * a) \方程有两个实根\
ElseIf col = 0 Then
\方程有两个相等实根\ Else
x1 = Sqr(-col) / (2 * a)
\方程有两个虚根\ End If Else
If (14) Then root1 = -b / c
\方程仅有一个根\ Else
\方程无意义\ End If End If End Sub
Private Sub Command2_Click() Text1(0).Text = \ Text1(1).Text = \ Text1(2).Text = \ Pic1. (15) End Sub
12.下列程序运行后如图5所示。给定的程序不完整,将程序补充完整。
图5
Private Sub form_Click() k = 7
For i = 5 To 1 Step -2
Print Tab(k); (16) k = k + 1 Next i End Sub 13.运行下列程序:
Private Sub Command1_Click() Dim s As Integer, i As Integer s = 0
For i = To Step s = s + 1 Next i Print s End Sub
单击Command1命令按钮后,则在窗体上显示的结果是 (17) 。
14.下列程序中有一个按钮Command1,一个文本框text1,其属性MultiLine=True。当单击按钮后,文本框显示 (18) 行数据,其中第二行和第三行的数据分别是 (19) 和 (20) 。
Option Explicit
Private Sub Command1_Click() Dim a As Single, i As Integer a = For i = 1 To 3 a = a * i Print fun1(a) Next i End Sub
Private Function fun1(t As Single) As Single Static y As Single y = y + t t = y + 1 fun1 = t End Function
15.要打印出50个在-100~100之间不同的随机整数,并找出第几个是最大数。给定的程序不完整,将程序补充完整。
Option Base 1
Private Sub Command1_Click() Dim b() Randomize (21) Do x = Rnd
If x > Then y = 1 Else y = -1 t = y * Int(Rnd * 100) + 1 (22) Do While k < j If t <> b(k) Then k = k + 1 Else Exit Do End If Loop If k = j Then
ReDim Preserve b(k) b(k) = t Print b(k); j = j + 1 End If Loop Until j > 50 Print (23) Max = b(1) For n = 2 To 50
If b(n) > Max Then (24) p = n End If Next n
Print \最大数是:\ Print \位置在第\个\End Sub
16.有下列程序,运行后变量x1、y1和z1的结果分别是 (25) 、 (26) 和 (27) 。
Private Sub fun1(s, m, n) s = m + 1 m = n + 2 n = s + 3 End Sub
Private Sub form_Click() Dim x1, y1 x1 = 1 y1 = 1 z1 = 1
Call fun1(x1, y1 + 1, (z1)) x1; y1; z1 End Sub 17.编写一过程把C盘中的文件内容读出,并在文本框中显示出来。在窗体Form1上建立一个文本框Text1,将其MuhiLine属性设置为True,ScrollBars属性设置为3-Both。给定的程序不完整,将程序补充完整。
Option Explicit
Private Sub Form_Click()
Dim ch1 As String, fn As Integer Dim Str As String fn = (28) Open \ Do While Not EOF( (29) ) Line Input #fn, ch1 Str = Str + ch1 + vbCrLf Loop
= (30) End Sub
二级Visual Basic全真模拟试卷一参考答案
一、选择题:
1.B2.D3.B4.C5.A6.A7.B8.D9.A10.A11.D12.C13.B14.D15.C16.C17.D18.B19.B20.C 21.C22.D23.A24.B25.B26.B27.C28.D29.A30.D二、填空题:(1)文件号(2)3(3)开/关 (4)Index(5)字符串(6)12(7)33(8)Val(Text1(i).Text)(9)x(i)>x(j)(10)Len(s1) To 1 Step-1 (11)n(k) Mod 2<>0(12)b^2-4*a*c(13)col>0(14)b<>0(15)Cls(16)String(i,\(17)7 (18)(19)(20)(21)j=1(22)k=1(23)p=1(24)Max=b(n)(25)3(26)1(27)1 (28)FreeFile(29)fn(30)Str
二级Visual Basic全真模拟试卷二
1.下列关于“信息系统”的叙述中错误的是 1 。
A.图书馆是一种以信息收藏和检索为主的系统 B.雷达是一种以感知与识别为主要目的的系统 C.信息系统可以有人工的,也可以有自动的