<% '******************************************************* '* ASP 101 Sample Code - http://www.asp101.com/ * '* * '* This code is made available as a service to our * '* visitors and is provided strictly for the * '* purpose of illustration. * '* * '* http://www.asp101.com/samples/license.asp * '* * '* Please direct all inquiries to webmaster@asp101.com * '******************************************************* %> <% ' This is a simple subroutine that takes three ' integer parameters and simply increments each ' by 1. The only difference is that for the ' first one I don't specify how the parameter ' should be passed, for the second I indicate ' that the parameter should be passed by ' reference (ByRef), and for the third I ' indicate that it should be passed by value ' (ByVal). Sub SampleSub(parDefault, ByRef parByRef, ByVal parByVal) parDefault = parDefault + 1 parByRef = parByRef + 1 parByVal = parByVal + 1 End Sub ' Declare our variables Dim intDefault ' This is the variable that I'll pass ' to the parameter that doesn't ' specify anything. Dim intByRef ' This variable I'll pass ByRef Dim intByVal ' This variable I'll pass ByVal ' Set all our variable to the same value. intDefault = 1 intByRef = 1 intByVal = 1 ' Display the variable values before: %>

Values Before Calling the Sub:
intDefault = <%= intDefault %>
intByRef = <%= intByRef %>
intByVal = <%= intByVal %>

Now Calling:
SampleSub(intDefault, intByRef, intByVal)

<% ' Call the sub passing our three variables in ' as parameters. Call SampleSub(intDefault, intByRef, intByVal) ' Display the variable values after: %>

Values After Calling the Sub:
intDefault = <%= intDefault %>
intByRef = <%= intByRef %>
intByVal = <%= intByVal %>