COMPUTER LANGUAGES HTML,C,C++.JAVA,.NET AND MULTIMEDIA basics and programs click home button
ADVANCED VB SCRIPT
Advanced VBScript
16. PROCEDURES
What is a Function?
A function is a group of reusable code which can be called anywhere
in your program. This eliminates the need of writing same code over
and over again. This will enable programmers to divide a big program
into a number of small and manageable functions. Apart from inbuilt
Functions, VBScript allows us to write user-defined functions as well.
This section will explain you how to write your own functions in VBScript.
Function Definition
Before we use a function, we need to define that particular function.
The most common way to define a function in VBScript is by using the
Function keyword, followed by a unique function name and it may or may
not carry a list of parameters and a statement with an End Function
keyword, which indicates the end of the function. The basic syntax is shown below:
<!DOCTYPE html>
<html>
<body>
<script language="vbscript" type="text/vbscript">
Function Functionname(parameter-list)
statement 1
statement 2
statement 3
.......
statement n
End Function
</script>
</body>
</html>
Example
<!DOCTYPE html>
<html>
<body>
<script language="vbscript" type="text/vbscript">
Function sayHello()
msgbox("Hello there")
End Function
</script>
</body>
</html>
No comments:
Post a Comment