adsense


Sunday, 8 November 2015

ADVANCE VB SCRIPT ADVANCED CONCEPTS FOR FUNCTION PAGE 93

COMPUTER LANGUAGES HTML,C,C++.JAVA,.NET AND MULTIMEDIA basics and programs click home button




ADVANCE VB SCRIPT ADVANCED CONCEPTS FOR FUNCTION





Advanced Concepts for Functions 


There is lot to learn about VBScript functions. We can pass the 
parameter byvalue or byreference. Please click on each one of them to know more. 

• ByVal - Pass the parameters by value 

• ByRef - Pass the parameters by the reference 

 
VBScript 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 


No comments: