Difference betn Createobject and New (URGENT)

Results 1 to 3 of 3

Thread: Difference betn Createobject and New (URGENT)

  1. #1
    Join Date
    Dec 1969

    Default Difference betn Createobject and New (URGENT)

    Can anybody explain me the difference between createobject and new? Its urgent<BR><BR>Thanks

  2. #2
    Join Date
    Dec 1969

    Default RE: Difference betn Createobject and New (URGENT)

    New is not a valid construct of VBScript. Perhaps you are thinking of VB, where you can say <BR><BR>&nbsp;&nbsp;&nbsp;dim objMyObject as new clsObject<BR><BR>??

  3. #3
    Join Date
    Dec 1969

    Default Answer only partly correct...

    With the addition of the CLASS keyword and user-defined types in VBScript version 5, you *CAN* now use the NEW keyword to create instances of your own classes.<BR><BR>However, in VBScript, that is the *only* valid use of NEW. <BR><BR>To create instances of ActiveX objects, you must always use Server.CreateObject. (You *can* use just CreateObject, but it creates the ActiveX object in the wrong "context" and can have a few strange and wonderful consequences.)<BR><BR>Incidentally, you can *NOT* use CreateObject or Server.CreateObject with user-defined classes. For them, *only* the NEW keyword works. Go figure.<BR><BR>(Actually, it makes perfect sense. User-defined classes in VBScript are *not* objects in the conventional sense of the word; they are really just "collections" with elements that are accessed via their property and method names in a bit more convenient way than Scripting.Dictionary presents. But they don&#039;t really have a lot more functionality or speed than a dictionary and, for example, cannot be stored in Session or Application variable values, thus demonstrating that they aren&#039;t "first class" [yes, that&#039;s a real compsci term] objects.)<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts