r = fun(n)
Print r
End Sub
程序运行后,单击命令按钮,输入1234,输出结果为:24
7. 阅读程序:
Function func(a%, b%) As Integer
Static m As Integer, i As Integer
m = 0
i = 2
i = i + m + 1
m = i + a + b
func = m
End Function
Private Sub command1_click()
Dim k%, m%, p%
vb试题及答案83_vb答案
k = 4
m = 1
p = func(k, m)
Print p;
p = func(k, m)
Print p
End Sub
程序运行后,单击命令按钮,输出结果为:8 8
8. 阅读程序:
Dim a%, b%, c%
Public Sub p1(x%, y%)
Dim c%
x = 2 * x: y = y + 2: c = x + y
End Sub
Public Sub p2(x%, ByVal y%)
Dim c%
x = 2 * x: y = y + 2: c = x + y
End Sub
Private Sub command1_click()
a = 2: b = 4: c = 6
Call p1(a, b)
Print a, b, c
Call p2(a, b)
Print a, b, c
End Sub4 6 6
程序运行后,单击命令按钮,输出结果为:8 6 6
9. 阅读程序:
Private Sub command1_click()
Dim m%, i%, x%(10)
For i = 0 To 4
x(i) = i + 1
Next i
For i = 1 To 2
Call proc(x())
Next i
For i = 0 To 4
Print x(i)
Next i
End Sub
Public Sub proc(a%())
Static i%
Do
a(i) = a(i) + a(i + 1)
i = i + 1
Loop While i < 2
End Sub
程序运行后,单击命令按钮,输出结果为:3 5 7 4 5
10. 阅读程序:
Private Sub command1_click()
Print p1(3, 7)
End Sub
Public Function p1!(x!, n%)
If n = 0 Then
p1 = 1
Else
If n Mod 2 = 1 Then
p1 = x * p1(x, n \ 2)
Else
p1 = p1(x, n \ 2) \ x
End If
End If
End Function程序运行后,单击命令按钮,输出结果为:27
11. 阅读程序:
Private Sub command1_click()
Dim x%, y%, z%, w%
x = 9
y = 8
z = 2
w = 6
Call s1(x, y, z, w)
Print x; y; z; w
End Sub
Private Sub s1(a%, b%, ByVal c%, ByVal d%)
a = a + 1
b = b + 2
c = c + 3
d = d + 4
End Sub程序运行后,单击命令按钮,输出结果为:10 10 2 6
12. 阅读程序:
Private Sub command1_click()
Dim x%, y%
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-22730-20.html
降低定期存款利率等于变相降【税】
自己没理由把伊拉克打碎了还在干协别人站队
是央行拿捏恰当
公布一件事情要顾全大局