Wednesday, July 20, 2011

VbScript Statement





The Call statement can be used for calling a function or subroutine. Note that the use of Call is optional. In other words, you can call a function or subroutine by simply stating the function's or subroutine's name. If you use Call and if there are one or more arguments to be passed you must enclose all of the arguments in parentheses. If you do not use Call, do not use the parentheses. If you use Call to call a function, the return value of the function is discarded. Code:




<% Call afunction %>




<% afunction %>




<% Call myfunction(myvar1, myvar2, mystring, myarray) %>




<% myfunction myvar1, myvar2, mystring, myarray %>




<% Call anysubroutine(anum, astring) %>




<% anothersubroutine %>










The Class statement block is used to create a Class object. You can only create (name) one Class object with each Class statement. This ability to create your own Class is a significant expansion of the usefulness of the VBScript language. Within the block of the Class statement you can declare the members of the class, which are variables, methods, and properties. Methods of the class are implemented by defining a Sub or Function procedure, while properties are defined through the use of Property Get, Property Let, and Property Set statements. Any member of a class may be declared as either Public or Private, with a Public declaration being the default state. Private members of a class are only accessible by other members of the same class, while Public members are accessible by anything, inside or outside of the scope of the class. The Class statement must always end with an End Class.




Example: <% Class DevGuruProducts ' Creating a private property using Get, Let, Set Private mstrName ' Get Public Property Get CustomerName() CustomerName = mstrName End Property ' Let Public Property Let CustomerName(strName) mstrName = strName End Property ' Set Public Property Set Guru(objGuru) Private mobjGuru Set mobjGuru = objGuru End Property ' Creating a private method using a function Private Function DevGuruProductName(intProduct) Select Case intProduct Case 1 DevGuruProductName = "dgCharge" Case 2 DevGuruProductName = "dgList" Case 3 DevGuruProductName = "dgReport" End Function End Class %>
































































Set










































No comments: