- Function SumTheNumber(nNumber)
- dim s,a
- for a=1 to nNumber step 1
- s=s+a
- next
- MsgBox "The Result is "&s,,"Result"
- End Function
-
- dim nResult
- nResult=SumTheNumber(inputbox("Input a number","Input the number"))
复制代码 Wmi教程里面写到,function是返回数值的,但是我只有在function中使用msgbox的时候才能显示出结果,如果把代码写成这样- Function SumTheNumber(nNumber)
- dim s,a
- for a=1 to nNumber step 1
- s=s+a
- next
- End Function
-
- dim nResult
- nResult=SumTheNumber(inputbox("Input a number","Input the number"))
- MsgBox "The Result is "&nResult,,"Result"
复制代码 就无法显示出结果来,想请教一下这是为什么,谢谢!
[ 本帖最后由 zcy85611 于 2009-3-10 13:00 编辑 ] |