2. 定义和调用函数或过程时参数传递的两种方法是(按值传递,按地址传递)。
3. 在窗体的通用段用Dim语句定义的变量是(窗体)级变量,它只能在(本窗体)中使用。
4. 全局级过程在定义时可以默认,也可以使用关键字( Public )进行显示声明;窗体/模块级的过程声明时
要用关键字( Private)。
5. 用ParamArray关键字声明可变参数时,被声明的参数只能是(变体类型数组)。
6. 在带可选参数的过程中,使用(IsMissing )函数来测试可选参数是否被选。
三、分析运行结果
1. 阅读程序
Function f(a As Integer)
Static c
b = 0:b = b + 1
c = c + 1: f = a + b + c
End Function
Private Sub command1_click()
Dim a As Integer
a = 2
For i = 1 To 3
Print f(a);
Next i
End Sub程序运行后,单击命令按钮,输出结果为:4 5 6
2. 阅读程序
Sub s(x As Single, y As Single)
t = x
x = t / y
y = t Mod y
End Sub
Private Sub command1_click()
Dim a As Single, b As Single
a = 5
b = 4
s a, b
Print a, b
End Sub
程序运行后,单击命令按钮,输出结果为:1.25 1
3. 阅读程序
Function M(x%, y%) As Integer
M = IIf(x > y, x, y)
End Function
Private Sub command1_click()
Dim a As Integer, b As Integer
a = 1
b = 2
Print M(a, b)
End Sub
程序运行后,单击命令按钮,输出结果为:2
4. 阅读程序
Sub Inc(a As Integer)
Static x As Integer
x = x + a
Print x;
End Sub
Private Sub command1_click()
Inc 2
Inc 3
Inc 4
End Sub
程序运行后,单击命令按钮,输出结果为:2 5 9
5. 阅读程序:
Sub p(b() As Integer)
For i = 1 To 4
b(i) = 2 * i
Next i
End Sub
Private Sub command1_click()
Dim a(1 To 4) As Integer
a(1) = 5
a(2) = 6
a(3) = 7
a(4) = 8
p a()
For i = 1 To 4
Print a(i);
Next i
End Sub程序运行后,单击命令按钮,输出结果为:2 4 6 8
6. 阅读程序:
Function fun(ByVal num As Long) As Long
Dim k As Long
k = 1
num = Abs(num)
Do While num
k = k * (num Mod 10)
num = num \ 10
Loop
fun = k
End Function
Private Sub command1_click()
Dim n As Long, r As Long
n = Val(InputBox("请输入一个数:"))
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-22730-19.html
送测啊
应该说爱卿所言甚是
大家觉得你非常好