|
| |||||||||
| Tags: c program, create, document write, functions, vbscript |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| How to create Functions in VBScript?
Hi friends, I am new to the scripting. I have done C, C++ and VB. But I am totally new for the scripting part. I have started recently with the VBScript. Can anyone explain me how to create functions in VBScript? Because I know that using the function will definitely decrease my coding lines. So I am very eager to create the functions. Please help me by providing some sample of coding for creating the function in VBScript.!! ![]() |
|
#2
| |||
| |||
| Re: How to create Functions in VBScript?
You are absolutely right, that using the function will reduce your coding lines in the program. When you write the exact code, functions are also useful to increase code readability. all the programs that you write will benefit from functions. Whether you use the pre-made functions like document.write() or make your own it is a necessity for any programmer to have a basic understanding of how functions work in VBScript. So it will be better to use the functions in VBScript. |
|
#3
| |||
| |||
| Re: How to create Functions in VBScript?
Since you are new in VBScript, lets use some simple function for an example. The function myAdd will take two numbers and print out the result. The following is the code in VBScript for that example : Code: <script type="text/vbscript">
Function myAdd(x,y)
myAdd = x + y
End Function
'Let's use our first function!
Dim result
result = myAdd(12,18)
document.write(result)
</script> Code: 30 |
|
#4
| ||||
| ||||
| Re: How to create Functions in VBScript?
The Function and End Function keywords defines the function in VBScript. The following is the method used for creating VBScript functions :
Code: Function add(number1,number2) add = number1 + number2 End Function |
|
#5
| ||||
| ||||
| Re: How to create Functions in VBScript?
The following example demonstrates the creating and calling a VBScript function. Code: <script type="text/vbscript"> Function add(number1,number2) add = number1 + number2 End Function Dim total total = add(15,10) document.write(total) </script> Code: 25
__________________ I do to dead flowers what people at morgues do to dead people. Suck all the moisture out, dip them in plastic, paint them up pretty and put them in a nice frame. |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "How to create Functions in VBScript?" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to create factorial of numbers using sub procedure in vbscript | Gurseerat | Software Development | 1 | 1 Week Ago 12:21 PM |
| How to create ZIP Files from Command-Line via VBScript? | FB | Windows Server Help | 10 | 22-12-2011 12:18 AM |
| How to create procedures in VBScript | Betelgeuse | Software Development | 4 | 30-11-2010 01:45 AM |
| Vbscript to create sites on a windows 2008 DC | Dipti Seth | Active Directory | 2 | 29-05-2010 06:14 PM |
| how to create automatic self extracting zip file in vbscript | vivekmohan | Software Development | 1 | 03-09-2009 10:10 AM |