[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[已解决]关于VBS中Function的迷惑

  1. Function SumTheNumber(nNumber)
  2. dim s,a
  3. for a=1 to nNumber step 1
  4. s=s+a
  5. next
  6. MsgBox "The Result is "&s,,"Result"
  7. End Function
  8. dim nResult
  9. nResult=SumTheNumber(inputbox("Input a number","Input the number"))
复制代码
Wmi教程里面写到,function是返回数值的,但是我只有在function中使用msgbox的时候才能显示出结果,如果把代码写成这样
  1. Function SumTheNumber(nNumber)
  2. dim s,a
  3. for a=1 to nNumber step 1
  4. s=s+a
  5. next
  6. End Function
  7. dim nResult
  8. nResult=SumTheNumber(inputbox("Input a number","Input the number"))
  9. MsgBox "The Result is "&nResult,,"Result"
复制代码
就无法显示出结果来,想请教一下这是为什么,谢谢!

[ 本帖最后由 zcy85611 于 2009-3-10 13:00 编辑 ]
1

评分人数

    • Batcher: 感谢主动给标题标注[已解决]字样PB + 2

谢谢各位的解答,弄懂了!

TOP

返回列表