- 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 - 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 ByVal Parameters
What are ByVal Parameters?
If ByVal is specified, then the arguments are sent as byvalue when the function or procedure is called.
Example
<!DOCTYPE html>
<html>
<body>
<script language = "vbscript" type = "text/vbscript">
Function fnadd(Byval num1, Byval 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 values. Hence, after executing the function, the values are unchanged.
If the above function is saved as .html and executed in IE, the output would be as follows −
The value of x is 6 The value of y is 4
vbscript_procedures.htm
Advertisements