aaa |
1(单选题): 可以作为VB应用程序启动对象的是______。 A. ①④ B. ①② C. ③④ D. ②③ D 解析:在VB中,能作为启动对象的包括窗体模块,sub main过程。 3 表达式37.6 Mod 5的结果数据类型为______。 A. 整型 B. 长整型 C. 单精度 D. 双精度 B 解析:Mod运算符的作用是取余数,要求Mod左右两边都是整型或长整型,首先将双精度类型37.6转换为长整型38,然后再执行38 Mod 5,根据VB约定,两个不同的类型的数值运算时返回的是占字节多的类型,因为长整型数值38占4个字节,整型5占2个字节,所以得到结果长整型3,如果直接写 37 mod 5因为37与5都是整型,所以返回结果整型2 。 3 在多窗体程序中,仅用于将窗体Form2从内存中卸载的语句是______。 A. Form2.Unload B. Unload Form2 C. End D. Form2.Hide B 解析:A选项没有这种写法,C选项是结束整个程序运行,D选项是Form2隐藏。 2 下列关于Len函数的叙述,错误的是________。 A. 该函数可以接收数值型常量作为其参数 B. 该函数可以接收数值型变量作为其参数 C. 该函数可以接收字符型常量作为其参数 D. 若该函数的参数为非字符型变量,则其返回该类型变量所占用的存储空间的大小 A 解析: 该函数不可以接收数值型常量作为其参数 。 3 Sub过程与Function过程最根本的区别是____。 A. Sub过程使用Call语句或直接使用过程名调用,而Function过程不可以 B. Function过程可以有参数,Sub过程不可以 C. 两种过程参数的传递方式不同 D. Sub过程的过程名不能返回值,而Function可以 D 解析: Sub过程的过程名不能返回值,而Function过程名可以返回值是两者最根本的区别。 7 6 (填空题 <2空> ) : 执行下面程序,单击Command1按钮,则a(1)的值是____________ ,a(4)的值是____________ 。 Option Explicit Option Base 1 Private Sub Command1_Click() Dim a(4) As Integer, i As Integer For i = 1 To 4 a(i) = F1(a, i) + a(i) Next i For i = 1 To 4 Print a(i) Next i End Sub Private Function F1(a() As Integer, x As Integer) As Integer Dim i As Integer If i Mod 2 <> 0 Then a(x) = x Else F1 = F1 + x End If End Function 1@4 解析: 因为文字描述不如视频清晰,具体见视频详细讲解 7 7 (填空题 <2空> ) : 执行下面程序,单击Command1按钮,则窗体上显示的数组元素a(2)的值是____________ ,a(3)的值是____________ 。 Option Explicit Option Base 1 Private Sub Command1_Click() Dim a(3) As Integer, b As Integer, i As Integer For i = 1 To 3 a(i) = i Next i b = UBound(a) Call sub1(a, b) For i = 1 To 3 Print a(i); Next i End Sub Private Sub sub1(m() As Integer, n As Integer) If n > 1 Then m(n) = m(n) + n Call sub1(m, n - 1) End If End Sub 4@6 解析: 因为文字描述不如视频清晰,具体见视频详细讲解 7 8 (填空题 <3空> ) : 执行下面程序,单击命令按钮Command1,窗体上显示的第一行内容是____________ ,a数组元素的个数是____________ ,其中a(2)的值是____________ 。 Option Explicit Option Base 1 Private Sub Command1_Click() Dim St As String, i As Integer Dim a() As String, j As Integer, k As Integer St = "abcd" Call Sub1(St) Print St For i = 1 To Len(St) For j = i + 1 To Len(St) If Mid(St, i, 1) = Mid(St, j, 1) Then Exit For Next j If j <= Len(St) Then k = k + 1 ReDim Preserve a(k) a(k) = Mid(St, i, 1) Print a(k) End If Next i End Sub Private Sub Sub1(S As String) Dim i As Integer For i = 1 To Len(S) \ 2 Mid(S, i, 1) = Mid(S, Len(S) - i + 1, 1) Next i End Sub dccd@2@c 解析: 因为文字描述不如视频清晰,具体见视频详细讲解 7 9 (填空题 <3空> ) : 执行下面程序,单击命令按钮Command1,则a(1,2)的值是____________ ,a(2,3)的值是____________ ,a(3,3)的值是____________ 。 Option Explicit Option Base 1 Private a(3, 3) As Integer Private Sub Form_Activate() Dim i As Integer, j As Integer, k As Integer k = 1 For i = 1 To 3 For j = 1 To 3 a(i, j) = k k = k + 1 Next j Next i End Sub Private Sub Command1_Click() Dim b(4) As Integer, i As Integer, j As Integer, t As Integer b(1) = 2 For i = 2 To 4 b(i) = i - 1 Next i t = a(b(1), b(4)) a(b(1), b(4)) = a(b(2), b(1)) a(b(2), b(1)) = a(b(3), b(2)) a(b(3), b(2)) = a(b(4), b(3)) a(b(4), b(3)) = t For i = 1 To 3 For j = 1 To 3 Print a(i, j); Next j Print Next i End Sub 4@2@9 解析: 因为文字描述不如视频清晰,具体见视频详细讲解 7 1(完善程序): 【要求】 1)打开T盘中“P1.vbp”文件,完善程序后,直接保存所有文件。 【题目】 下面程序的功能是,随机生成10个不含数字0且由5位不同数字组成的整数,再将所生成的五位整数转换为由组成该数的数字构成的最小整数后输出。 Option Explicit Private Sub Command1_Click() Dim a(1 To 10) As Long, b(0 To 9) As Boolean, c(1 To 5) As Integer Dim i As Integer, j As Integer, k As Integer, n As Long For i = 1 To 10 n = Int(Rnd * 90000) + 10000 Erase b b(0) = True For j = 1 To 5 c(j) = Mid(n, j, 1) If b(c(j)) = False Then b(c(j)) = True Else (1) End If Next j If j = 6 Then Call Sort(c) For k = 1 To 5 a(i) = a(i) * 10 + c(k) Next k List1.AddItem a(i) Else (2) End If Next i End Sub Private Sub Sort(a() As Integer) Dim i As Integer, t As Integer, ub As Integer, f As Boolean ub = UBound(a) f = True Do While f (3) ub = ub - 1 For i = 1 To ub If a(i) > a(i + 1) Then f = True (4) a(i) = a(i + 1) a(i + 1) = t End If Next i Loop End Sub Exit For@i=i-1@f=false@t=a(i) (1)Exit For (2)i=i-1 (3)f=false (4)t=a(i) 因为文字描述不如视频清晰,请查看自带的本题目的视频详细讲解 2(改错题): 【要求】 (1)打开T盘中“P2.vbp”文件,按参考界面形式编辑窗体界面,改正程序中的错误后,直接保存所有文件; (2)改错时,不得增加或删除语句,但可适当调整语句位置。 【题目】本程序的功能是:生成一个4×4的数组,并根据数组中元素的大小生成一个标记数组。在标记数组中字母“L”表示数组的对应位置元素为最大,字母“S”表示随组的对应位置元素为最小(若存在多个相等的最大或最小元素也用字母“L”与“S”标记),其他非最大最小元素均用“0”表示。 Option Explicit Dim a(4, 4) As Variant, i As Integer, j As Integer Private Sub Command1_Click() For i = 1 To 4 For j = 1 To 4 a(i, j) = Int(Rnd * 90) + 10 Next j Next i Call printsz(Picture1) End Sub Private Sub Command2_Click() Dim Max As Integer, Min As Integer, a(4, 4) As Integer Max = 0 Min = 0 For i = 1 To 4 For j = 1 To 4 If a(i, j) > Max Then Max = a(i, j) If a(i, j) < Min Then Min = a(i, j) Next j Next i Call bj(Max, Min) End Sub Private Sub bj(m As Integer, n As Integer) For i = 1 To 4 For j = 1 To 4 If a(i, j) = m Then a(i, j) = L ElseIf a(i, j) = n Then a(i, j) = S Else a(i, j) = "0" End If Next j Next i Call printsz(Picture2) End Sub Private Sub printsz(pic As Control) pic.Cls For i = 1 To 4 For j = 1 To 4 pic.Print a(i, j); " "; Next j pic.Print Next i End Sub Dim Max As Integer, Min As Integer, a(4, 4) As Integer修改为Dim Max As Integer, Min As Integer@ Max = 0修改为Max=a(1,1) Min = 0修改为Min=a(1,1)@ a(i, j) = L修改为a(i, j) = “L”@ a(i, j) = S修改为a(i, j) = “S” (1)Dim Max As Integer, Min As Integer, a(4, 4) As Integer修改为Dim Max As Integer, Min As Integer@ (2)Max = 0修改为Max=a(1,1) Min = 0修改为Min=a(1,1) (3)a(i, j) = L修改为a(i, j) = “L” (4)a(i, j) = S修改为a(i, j) = “S” 因为文字描述不如视频清晰,请查看自带的本题目的视频详细讲解 3(编程题): 【要求】 (1)打开T盘中“P3.vbp”文件,根据题目要求编写和调试程序后,直接保存所有文件; (2)程序代码书写应呈锯齿形,否则适当扣分。 【题目】 找出任意给定的两个自然数的相同因子(因子中不包含1和该数本身)。 【编程要求】 (1)程序参考界面如图所示,编程时不得增加或减少界面对象或改变对象的种类,窗体及界面元素大小适中,且均可见; (2)运行程序,单击“查找”按钮,根据文本框1和文本框2中给定的数字,分别求出它们除1和本身外的因子,并最终求出这两个数的相同因子输出在文本框3中,若两个数没有相同因子,则在文本框3中输出”没有相同因子”;单击“退出”按钮,则结束程序运行; (3)程序中必须包含一个求因子的通用过程。 Option Explicit Option Base 1 Private Sub Command1_Click() Dim a() As Integer, b() As Integer, c() As Integer Dim n1 As Integer, n2 As Integer Dim i As Integer, j As Integer, k As Integer n1 = Text1.Text n2 = Text2.Text Call yinzi(n1, a) Call yinzi(n2, b) For i = 1 To UBound(a) For j = 1 To UBound(b) If a(i) = b(j) Then k = k + 1 ReDim Preserve c(k) c(k) = a(i) End If Next j Next i Text3.Text = n1 & "的因子: " For i = 1 To UBound(a) Text3.Text = Text3.Text & a(i) & " " Next i Text3.Text = Text3.Text & vbCrLf Text3.Text = Text3.Text & n2 & "的因子: " For i = 1 To UBound(b) Text3.Text = Text3.Text & b(i) & " " Next i Text3.Text = Text3.Text & vbCrLf If k = 0 Then Text3.Text = Text3.Text & "没有相同的因子数:" Else Text3.Text = Text3.Text & "相同的因子数:" For i = 1 To UBound(c) Text3.Text = Text3.Text & c(i) & " " Next i End If End Sub Private Sub Command2_Click() End End Sub Private Sub yinzi(n As Integer, c() As Integer) Dim i As Integer, k As Integer For i = 2 To n - 1 If n Mod i = 0 Then k = k + 1 ReDim Preserve c(k) c(k) = i End If Next i End Sub 因为文字描述不如视频清晰,请查看自带的本题目的视频详细讲解 |