rem function有返回值,sub无返回值
rem -------------function: 无参数,无返回值-------------
rem 定义
rem function hello()
rem msgbox("hello")
rem end function
rem 调用
rem hello()
rem -------------function: 1参数,无返回值-------------
rem 定义
rem function hi(name)
rem msgbox("hi " & name)
rem end function
rem 调用
rem hi("xiaohei")
rem -------------function: 多参数,有返回值-------------
rem 定义
rem function myadd(a, b, c)
rem dim result
rem result = a + b + c
rem myadd = result
rem end function
rem 调用
rem msgbox(myadd(10, 20, 30))
rem -------------sub: 无参数,无返回值-------------
rem 定义
rem sub hello()
rem msgbox("hello")
rem end sub
rem 调用
rem hello()
rem -------------sub: 有参数,无返回值-------------
rem 定义
rem sub hi(name)
rem msgbox("hi " & name)
rem end sub
rem 调用
rem hi("xiaohei")
vbs教程《函数过程》
最新推荐文章于 2023-12-28 09:53:00 发布