
- VBScript Tutorial
- VBScript - Home
- VBScript - Overview
- VBScript - Syntax
- VBScript - Enabling
- VBScript - Placement
- VBScript - Variables
- VBScript - Constants
- VBScript - Operators
- VBScript - Decisions
- VBScript - Loops
- VBScript - Events
- VBScript - Cookies
- VBScript - Numbers
- VBScript - Strings
- VBScript - Arrays
- VBScript - Date
- VBScript Advanced
- VBScript - Procedures
- VBScript - Dialog Boxes
- VBScript - Object Oriented
- VBScript - Reg Expressions
- VBScript - Error Handling
- VBScript - Misc Statements
- VBScript Useful Resources
- VBScript - Questions and Answers
- VBScript - Quick Guide
- VBScript - Useful Resources
- VBScript - Discussion
VBScript ByRef Parameters
What are ByRef Parameters?
If ByRef is specified, then the arguments are sent as a reference when the function or procedure is called.
Example
<!DOCTYPE html> <html> <body> <script language = "vbscript" type = "text/vbscript"> Function fnadd(ByRef num1, ByRef num2) num1 = 4 num2 = 5 End Function Dim x,y x = 6 y = 4 res = fnadd(x,y) document.write("The value of x is " & x & "<br />") document.write("The value of y is " & y & "<br />") </script> </body> </html>
The above function takes the parameter x and y as by reference. Hence, after executing the function, the values are changed.
If the above function is saved as .html and executed in IE, the output would be as follows −
The value of x is 4 The value of y is 5
vbscript_procedures.htm
Advertisements