10.2.2- Creating an instance of a VBScript object
Created
by Brendan Doss.
|
| << 10.2.1- Creating an Instance of a Scripting Runtime Object | Chapter10 | 10.3.0- The Dictionary Object >> |
Creating an instance of a VBScript object
When using objects from the VBScriptlibrary, as well as using the above method to create an object,you can also create an instance of the object by using the keyword New. However, theNew keyword can only be used to create aninstance of a VBScript class or built-in VBScript object, not a generic object(such as a scripting runtime one). So, you coulddo this for the RegExp (regular expression) object. It works in a similarway to the CreateObject method, although it doesn't require the ProgID,rather just the name of the object:
Set objRegExp = New RegExp
The difference is that CreateObject goesthrough COM for creation while New means the object goes to the VBScript runtime engine.At the moment you don't need to worry about why this happens, but you need tobe aware that it is preferable for your object to be created by COM if youintend it to use it in either a secure application, or one that involvestransactions.
Since dealing with data isvery important to a lot of web applications, let's take a look at how the Dictionary object allowsyou to manipulate sets of data very easily.
| << 10.2.1- Creating an Instance of a Scripting Runtime Object | Chapter10 | 10.3.0- The Dictionary Object >> |

RSS
