Results 1 to 2 of 2

Thread: How to create a new instance of a class at runtime?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2001
    Posts
    13

    Question

    I've been trying to dinamically create instances of a class that I created but it seems that VB6 does not provide a lot of support on this topic.

    I can use:
    Code:
    public myClass as new classType
    or
    Code:
    dim myClass as new classType
    but it is not enough.

    Is there anything like a pointer to a class like in C++? Say, what is the equivalent of this in VB:
    Code:
    myClass *pointer;
    
    pointer = new myClass;
    
    .
    .
    .

    Thanks!

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Well, you can declare an object reference:
    Code:
    Dim x as MyClass
    Dim y as New MyClass
    
    Set x = New MyClass
    Set x = Nothing ' Destroy
    
    Set x = y
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

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