Results 1 to 6 of 6

Thread: Initialize a Class

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2006
    Posts
    2

    Initialize a Class

    Hi, I want to initialize a variable having the name of a class. Is is possible or not? Thanks!

    Afzal_j56

  2. #2

  3. #3
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: Initialize a Class

    Basic class initialization:

    VB Code:
    1. ' declaration (ie. in general declarations)
    2. Dim Something As clsClassName
    3.  
    4. ' initialization for use (ie. on Form_Load)
    5. Set Something = New clsClassName
    6.  
    7. ' once done, clearing from memory (ie. on Form_Unload)
    8. Set Something = Nothing

    As far as I know, you can't create a new class by using a string variable.


    Edit
    1 AM
    Last edited by Merri; Aug 3rd, 2006 at 04:45 PM.

  4. #4
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Initialize a Class

    Quote Originally Posted by Merri
    VB Code:
    1. ' initialization for use (ie. on Form_Load)
    2. Set Something [COLOR=Red][B]=[/B][/COLOR] New clsClasName
    tut tut merri

  5. #5

    Thread Starter
    New Member
    Join Date
    Aug 2006
    Posts
    2

    Re: Initialize a Class

    I am Initialing my classes by the following way,
    CASE SomeValue
    Case 1
    Set Var1 = New Class1
    Case 2
    Set Var1 = New Class2
    and so on.
    Is there any way to Initialize these classes dynamically by keeping the Class Name in a variable (strVariable) and set as follows,
    Set Var1 = New strVariable

    Thanks in Advance.
    Last edited by Afzal_J56; Aug 3rd, 2006 at 04:41 PM.

  6. #6
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: Initialize a Class

    You can't create a new copy of a class with a string. What you're trying to achieve?

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