1.Sub 过程
Sub过程是包含在Sub和End Sub语句之间的一组VBScript语句,执行操作但不返回值。Sub过程可以使用参数。
例子:
Option Explicit
SayHelloToBill
Sub SayHelloToBill
Dim strMsg
strMsg="Hello,Bill.Welcome to our script"
MsgBox strMsg
End Sub
2.Function 过程
Function过程是包含在Function和End Function语句之间的一组VBScript语句。Function过程与Sub过程类似,但是Function过程可以有返回值。Function过程可以使用参数。
例子:
Option Explicit
Dim temp,fDegrees
ConvertTemp
Sub ConvertTemp()
temp=InputBox("请输入华氏温度:",1)
MsgBox "温度为:"&Celsius(temp)&"摄氏度"
End Sub
Function Celsius(fDegrees)
Celsius=(fDegrees-32)*5/9
End Function