ASP 101 - Active Server Pages 101 byrefbyval.aspx
<%@ Page Language="VB" %>
<script language="VB" runat="server">
	' Declare our variables
	Dim intDefault	' To be passed unspecified
	Dim intByRef	' To be passed ByRef
	Dim intByVal	' To be passed ByVal
	' 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(ByVal parDefault, ByRef parByRef, ByVal parByVal)
		parDefault = parDefault + 1
		parByRef = parByRef + 1
		parByVal = parByVal + 1
	End Sub
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>ByRef vs. ByVal ASP.NET Sample</title>
</head>
<body>
<%
' Set all our variables to the same value to begin
intDefault = 1
intByRef = 1
intByVal = 1
' Display the variable values before:
%>
<p>
<strong>Values Before Calling the Sub:</strong><br />
intDefault = <%= intDefault %><br />
intByRef   = <%= intByRef %><br />
intByVal   = <%= intByVal %>
</p>
<p>
<strong>Now Calling:</strong><br />
SampleSub(intDefault, intByRef, intByVal)
</p>
<%
' Call the sub passing our three variables in as parameters.
Call SampleSub(intDefault, intByRef, intByVal)
' Display the variable values after:
%>
<p>
<strong>Values After Calling the Sub:</strong><br />
intDefault = <%= intDefault %><br />
intByRef   = <%= intByRef %><br />
intByVal   = <%= intByVal %>
</p>
<hr />
<p>
Click <a href="http://www.asp101.com/samples/byrefbyval_aspx.asp">here</a>
to read about and download the source code.
</p>
</body>
</html>