Ch06-01-01.aspx 子程序、函数范例
' 这是从 1 连加到 N 的程序
Sub Count2N(ByVal intA As Integer)
Dim Totals As Integer = 0, I As Integer
For I = 1 to intA
Totals += I
Next
Response.Write("从1加到" & intA & "的总和为" & Totals & "")
End Sub
Function Add2N(ByVal intA As Integer)
Dim Totals As Integer = 0, I As Integer
For I = 1 to intA
Totals += I
Next
Return Totals ' 返回加总的结果
End Function
Dim Totals As Integer, Limits As Integer = 50
' 调用 Count2N 程序
Call Count2N(20)
Totals = Add2N(Limits)
Response.Write("从 1 加到 " & Limits & " 的总和为 " & Totals & "")
%>