VBScript TutorialIntroductionVBScript Editors VBScript Syntax VBScript Variables VBScript Arrays VBScript Date VBScript If Statements VBScript Select Case VBScript While Loop VBScript For Loop VBScript Operators VBScript Functions Summary Got a MySpace Page?Get "www.yourname.com" for your MySpace page. Learn how >>. |
VBScript FunctionsVBScript functions are self contained blocks of code that perform a given "function", or task. Sometimes when coding, you may find yourself having to write the same piece of code over and over again. If this happens, chances are, you'd be better off writing a function. That way, you can write the code once, then simply call the function whenever you need it. Creating VBScript FunctionsVBScript functions are defined using the Function and End Function keywords. The code that makes up the function resides between these two keywords. Here's the method for creating VBScript functions:
Example:
Calling VBScript FunctionsA function doesn't actually do anything until it is called. Once it is called, it takes any arguments, then performs it's function (whatever that may be). You call a VBScript function like this:
Example:
Combined - Creating, then Calling a VBScript FunctionSo, if we combine them together, and add a tiny bit more code, we might end up with something that looks like this:
Using the above code, the following is produced:
109
Enjoy this website?
Oh, and thank you for supporting Quackit! |
FREE Hosting!With every domain name you register with ZappyHost, you get FREE (ad supported) hosting.PLUS you get:
Featured Template:
(Build your websites in minutes!) |