问题
填空题
运行下列程序:
Dim t As Integer
Private Sub Form_Click()
t = 2
x=Val(InputBox("输入一个整数5"))
Print funl(x); t
End Sub
Private Function fun1(y)
If y>0 Then
fun1 = 1: t=10
Else If y=0 Then
fun1 = 0: t=20
Else
fun1 = -1: t=30
End If
End Function
从键盘为变量x输入数据5,输出的结果是 【8】 。
答案
参考答案:1 10
解析:
[分析]: t为模块级变量,在子函数中计算的结果10改变了主函数中的t值,fun1函数名返回的值为1。