Share via


NEWOBJECT( ) Function

Creates a new class or object directly from a .vcx visual class library or program.

NEWOBJECT(cClassName [, cModule [, cInApplication
   [, eParameter1, eParameter2, ...]]])

Return Values

Object

Parameters

  • cClassName
    Specifies the class or object from which the new class or object is created.

    OLE objects are created with the following syntax for cClassName:

    ApplicationName.Class
    

    For example, to create a Microsoft® Excel worksheet (which supports Automation), you can use the following syntax:

    oExcelSheet = NEWOBJECT('Excel.Sheet')
    
  • cModule
    Specifies a .vcx visual class library or Visual FoxPro program (.prg, .mpr, .app, .exe, and so on) containing the class or object specified with cClassName. The default is a .vcx visual class library; you must include an extension if you specify a program.

    Note   A class library can have an alias. To specify a class or object from a class library with an alias, include the class library alias followed by a period and the object name.

    If cModule is omitted, or is the empty string or the null value, Visual FoxPro searches for the class or object in the following order:

    • Visual FoxPro base classes.
    • Classes in the current program.
    • Class libraries opened with SET CLASSLIB.
    • Classes in procedure files opened with SET PROCEDURE.
    • Classes in the Visual FoxPro program execution chain.
    • The OLE registry if SET OLEOBJECT is ON.
  • cInApplication
    Specifies the Visual FoxPro application (.exe, or .app) containing the .vcx visual class library you specify with cClassLibName. You must include an extension for the application. CInApplication is ignored if cModule is omitted, or if cInApplication is the empty string or the null value.

  • eParameter1, eParameter2, ...
    Specifies optional parameters that are passed to the Init event procedure for the class or object.

Remarks

NEWOBJECT( ) makes it possible for you to create a new class or object without opening a .vcx visual class library or procedure file.

Use = or STORE to assign the object reference returned by NEWOBJECT( ) to a variable or array element. If an object assigned to a variable or array element is released, the variable or array element contains the null value. Use RELEASE to remove the variable or array element from memory.

See Also

Class Designer | CREATE CLASS | CREATE CLASSLIB | CREATEOBJECT( ) | DEFINE CLASS | NewObject Method