ArrayProcByRef(byvalArray, byrefArray) Console.WriteLine(UBound(byvalArray)) Console.WriteLine(UBound(byrefArray)) End Sub
Sub ArrayProcByRef (ByVal arr() As Integer, ByRef arr2() As Integer) Redim arr(100) Redim arr2(100) End Sub A. 10,100
B. 100,100 C. 10,10 D. 100,10
(注意,数组参数传递比较复杂,这个题目的内容没有讲过,不会考的)
14. 可以使用参数数组为过程传递不确定个数的参数,下面的函数声明都用到了参数数组,其中正确的是( A ? )。
A.Sub StudentScores(ByVal name As String, ByVal ParamArray scores( ) As String) B.Sub StudentScores(ByVal name As String, ByRef ParamArray scores( ) As String) C. Sub StudentScores(ByVal name As String, ByVal ParamArray scores(, ) As String)
D.Sub StudentScores(Optional ByVal name As String, ByVal ParamArray scores( ) As String) (注意,ParamArray是一个特殊的修饰符,这个题目的内容没有讲过)
15. 下列哪些语句将得到filename文件的扩展名(假设扩展名为3个字符)?( AD ? )。
A.Right(filename,3) B.Left(filename,3)
C. Left(filename,Len(filename)-3) D.Mid(filename,Instr(filename,”.”)+1)
16. 下列布尔表达式的值为 ( B ? )。
Not False And True Xor True Or False
A.True
B.False
C.OrElse D. AndAlso
17. 执行下列程序后,变量i的值和sum的值分别为 ( D )。
Dim i As Integer Dim sum As Integer For i = 0 To 100 Step 2
6
sum = sum + i
Next
A.102, 2500 B.100, 2500 C.100, 2550 D. 102, 2550
18. 执行下列代码后,变量count的值为 ( C )。
Dim count As Integer
For count = 10 To 0, Step -1 count = count - 3 Next A.0 B.-1 C. -2 D.-3
19. 下列关于Do循环说法正确的是( C )。
A.Do…Loop Until和Do Until…Loop都是在条件为假时退出循环 B.Do…Loop While和Do While…Loop都是在条件为假时退出循环 C. Do…Loop Until和Do…Loop While中的代码至少会执行一次 D.Do Until…Loop和Do While…Loop中的代码至少会执行一次
20. 要表示广州市的车牌号码,对输入有以下格式要求:( B )。
? 前面必须有汉字“粤”; ? 车牌为6位数; ? 车牌第一位为字母“A”,车牌最后一位必须为数字,其他位置字符数字不限; 下列对Masked Edit的Mask属性设置正确的是 A.粤AAAAA# B.粤\\AAAAA0 C.粤\\A????# D. 粤AAAAA9
三、编程题
1. 编写一个Function过程,求圆的面积(圆的半径作为过程的参数)。
(参考指定教程)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim r As Double
r = CType(TextBox1.Text, Double) TextBox2.Text = r * r * Math.PI MsgBox(TextBox2.Text)
End Sub
7
或者Private Function Calculate(ByVal Radius) As Double Dim RadiusDoubled As Double Dim dblResult As Double RadiusDoubled = Radius * Radius dblResult = RadiusDoubled * Math.PI Return dblResult End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim Area As Double Area = Calculate(100) MsgBox(\圆的面积是\ & Area)
End Sub
2. 编写程序,计算并输出所有6位正整数中能被6整除且其十位数不是4的数之和,并求它们中的最大数。
(结果:和:7.42508E+10 最大值:999996)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim I, max As Long Dim s As Single s = 0 : max = 100000
For I = 100000 To 999999
If ((I Mod 6 = 0) And (I Mod 100) \\ 10 <> 4) Then s = s + I
If (max < I) Then max = I End If End If Next I
MsgBox(\和是\ & s &”,” & \最大值是\ & max)) End Sub
3. 编写程序,计算并输出所有6位正整数中同时能被13和20整除的数的个数n及它们的立方根的和。
(结果:个数:3462 立方根和:275112.31253)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim n, i As Integer, s As Double n = 0 : s = 0
For i = 100000 To 999999
8
If i Mod 13 = 0 And i Mod 20 = 0 Then n = n + 1
s = s + i ^ (1 / 3) End If Next i
MsgBox(\个数是\ & n & “,” & \立方根的和是\ & s) End Sub
4. 编写程序,计算并输出下面级数前n项(n=40)中偶数项的和。
s = 1*2+2*3+3*4+4*5+……+n*(n+1)+… (结果:11900)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim n As Integer, s As Double s = 0
For n = 2 To 40 Step 2 s = s + n * (n + 1) Next n
MsgBox(\前40项中偶数项和S=\ & s) End Sub
5. 编写程序,计算并输出所有5位正整数中能被7整除且其十位数不是7的数之和,并求它们中的最大数。
(和:6.364356E+08 最大值:99995)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim I, max As Long Dim s As Single s = 0 : max = 10000 For I = 10000 To 99999
If ((I Mod 7 = 0) And (I Mod 100) \\ 10 <> 7) Then s = s + I
If (max < I) Then max = I End If End If Next I
MsgBox(\和是\ & s &”,” & \最大值是\ & max)) End Sub
9
6. 编写程序,统计10000到40000之间回文数的个数。(例:23732即为回文数,即正反读数据相同)
(结果:300)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i, j, p As Integer
Dim a, b, c, d, f As Integer p = 0
For i = 10000 To 40000 a = i Mod 10
b = (i Mod 100) \\ 10 c = (i Mod 1000) \\ 100 d = (i Mod 10000) \\ 1000 f = i \\ 10000
j = a * 10000 + b * 1000 + c * 100 + d * 10 + f If i = j Then p = p + 1 End If Next
MsgBox(p) End Sub
7. 编写程序,求5664,144的最大公约数。
(48)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim num1 As Integer Dim num2 As Integer Dim inlarge As Integer Dim insmall As Integer Dim inrem As Integer num1 = 5664 num2 = 144
If num1 < num2 Then inlarge = num2 insmall = num1 Else
inlarge = num1 insmall = num2 End If
inrem = inlarge Mod insmall While inrem <> 0
10
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库VBNET习题集汇编(2)在线全文阅读。
相关推荐: