CreateObject Function

The CreateObject function creates an object of a specified type.

Syntax

CreateObject(ObjectName)

Arguments:

ObjectName: Required. The name of the object.

Supported Object Names

  • Scripting.FileSystemObject
  • Scripting.Dictionary
  • System.Collections.ArrayList
  • ADODB.Connection
  • ADODB.RecordSet
  • WScript.Shell
  • VBScript.RegExp

The following example illustrates the use of the Createobject function:

Example 1:

Dim fso, tso
Set fso = CreateObject("Scripting.FileSystemObject")
Set tso = fso.CreateTextFile("C:\example.txt", True)
tso.WriteLine("Hello World!")
tso.Close