Saturday, December 6, 2008

VB Script Procedures

'There are two types of procedures

'1. Function Procedure
'2. Sub Procedure

'Function Procedure-A Function procedure is a series of VBScript statements enclosed by the Function
'and End Function statements. Function Procedure can able to return the value.

'Example:

Function demo_add(a,b)

demo_add=a+b

End Function

oVal=demo_add( 2,3)

msgbox oVal 'Returns 5

'In this example demo_add function returns a value to oVal.
'In Function procedures we can use function name to assign a value.

'Sub Procedure-A Sub procedure is a series of VBScript statements enclosed by the Sub
'and End Sub statements. Sub Procedure cannot return any value.

'Example:

Sub demo_sub(a,b, c)
c=a+b
End sub

demo_sub 2,3,x
msgbox x 'Returns 5

'This example will do the same as what function procedure is doing above.
'But in sub Procedure we need to use one more parameter to get values from the sub procedure.

No comments:

About Me

My photo
Hi all,I am Arun Singh Rajaputra. I am working as a Project Lead in a reputed organization in Hyderabad, AP, India. I have little bit knowledge on Quick Test Professional and like to share my knowledge to all through this blog.

Subscribe to get updates on this blog

Enter your email address:

NOTE

Some of the posts posted in this blog are collected and most of them have been prepared by me. If any one have objections regarding any copied posts. Please mail me so that I can take a necessary action on that post.