Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8123425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:10:53+00:00 2026-06-06T06:10:53+00:00

Given an object of type clsPerson: dim oP as New clsPerson oP.FirstName = Sam

  • 0

Given an object of type clsPerson:

dim oP as New clsPerson
oP.FirstName = "Sam"

is there a way to interrogate variable oP and a create a new object of that type?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T06:10:54+00:00Added an answer on June 6, 2026 at 6:10 am

    If the class is properly registered with COM (that is, coming from an ActiveX dll project), then yes:

    Option Explicit
    
    Private Type Guid
      Data1 As Long
      Data2 As Integer
      Data3 As Integer
      Data4(0 To 7) As Byte
    End Type
    
    Private Const CLSCTX_INPROC_SERVER As Long = 1
    Private Const IID_IUnknown As String = "{00000000-0000-0000-C000-000000000046}"
    
    Private Declare Function CLSIDFromString Lib "ole32.dll" (ByVal lpsz As Long, ByRef pclsid As Guid) As Long
    Private Declare Function IIDFromString Lib "ole32.dll" (ByVal lpsz As Long, ByRef lpiid As Guid) As Long
    Private Declare Function CoCreateInstance Lib "ole32.dll" (ByRef rclsid As Guid, ByVal pUnkOuter As Long, ByVal dwClsContext As Long, ByRef riid As Guid, ByRef ppv As Object) As Long
    
    
    
    Public Function GetAnotherInstanceOf(ByVal this As Object) As Object
      Static iunk As Guid
      If iunk.Data4(7) = 0 Then
        IIDFromString StrPtr(IID_IUnknown), iunk
      End If
    
      Dim ti As TLI.TypeInfo
    
      With New TLI.TLIApplication
        Set ti = .ClassInfoFromObject(this)
      End With
    
      Dim clsid As Guid
      CLSIDFromString StrPtr(ti.Guid), clsid
    
      CoCreateInstance clsid, 0, CLSCTX_INPROC_SERVER, iunk, GetAnotherInstanceOf
    End Function
    

    Usage:

    Dim s As New MSXML2.DOMDocument60
    
    Dim clone As Object
    
    MsgBox TypeName(clone)
    Set clone = GetAnotherInstanceOf(s)
    MsgBox TypeName(clone)
    

    The TLI is TypeLib Information found in Project -> References.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way I can construct an new object from the given object
Given an object, is there any way to get notified of when that object
Given: Object innerProxy = ... Object proxy = java.lang.reflect.Proxy. newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[]{type}, innerProxy); How
What's the easiest way, given a Type object, to test to see whether it
Is it possible to determine an object type's alias(es) through reflection? Given the following
Given object's SHA1 code, how could one identify the object type (blob, tree, tag,
I want to call my generic method with a given type object. void Foo(Type
I'm creating a dynamic function to create an object at runtime given an object[]
Given a collection IEnumerable<Type> supportedTypes What's the best way to check whether a given
I have a certain object type that is stored in a database. This type

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.