adsense


Showing posts with label ADVANCE VB SCRIPT RETURNING A VALUE FROM A FUNCTION. Show all posts
Showing posts with label ADVANCE VB SCRIPT RETURNING A VALUE FROM A FUNCTION. Show all posts

Sunday, 8 November 2015

ADVANCE VB SCRIPT RETURNING A VALUE FROM A FUNCTION PAGE 90

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




ADVANCE VB SCRIPT RETURNING A VALUE FROM A FUNCTION





Returning a Value from a Function 

A VBScript function can have an optional return statement. 
This is required if you want to return a value from a function. 
For example, you can pass two numbers in a function and then 
you can expect from the function to return their multiplication 
in your calling program. 
NOTE : A function can return multiple values separated by 
comma as an array assigned to the function name itself. 
Example 
This function takes two parameters and concatenates them and 
returns result in the calling program. In VBScript, the values 
are returned from a function using function name. In case if 
you want to return two or more values, then the function name 
is returned with an array of values. In the calling program, 
the result is stored in the result variable. 
<!DOCTYPE html> 
<html> 
<body> 
<script language="vbscript" type="text/vbscript"> 
 
  Function concatenate(first, last) 
    Dim full 
    full = first & last 
    concatenate = full  'Returning the result to the function name itself 
  End Function 
 
</script> 
</body> 
</html> 
Now, we can call this function as follows: 
<!DOCTYPE html> 
<html> 
<body> 
<script language="vbscript" type="text/vbscript"> 
 Function concatenate(first, last) 
    Dim full 
    full = first & last 
    concatenate = full  'Returning the result to the function name itself 
  End Function 
  ' Here is the usage of returning value from function.  
  dim result 
  result = concatenate("Zara", "Ali") 
  msgbox(result) 
</script> 
</body> 
</html>