Results 1 to 3 of 3

Thread: How to create object without using "NEW"?

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2003
    Posts
    11

    How to create object without using "NEW"?

    I want to create a instance of class, but it's only a "private" class in this project, so i can't use "CreateObject".

    and i can't know which class i want to create from. it's like this:

    private function createNewInstance(obj as object) as object

    end function

    i want this function return a new object like obj, but VB6 does not support reflection like .Net, so how can i do?

  2. #2
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246
    I assume the objects are things such as Command Buttons and Text Boxes?

    VB Code:
    1. Private Function CreateNewInstance(frm As Form, obj As Object)
    2. If TypeOf obj Is CommandButton Then
    3.     Set obj = frm.Controls.Add("VB.COMMANDBUTTON", "NewCommandButton")
    4.     obj.Visible = True
    5. End If
    6. End Function

    Is this what you are after?

    Phreak
    Last edited by «°°phReAk°°»; Apr 11th, 2004 at 10:12 AM.

    Visual Studio 6, Visual Studio.NET 2005, MASM

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2003
    Posts
    11
    It's not control
    Tt is just a class.

Posting Permissions

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



Click Here to Expand Forum to Full Width