Results 1 to 3 of 3

Thread: ***Resolved*** Create instance of object from string name

  1. #1

    Thread Starter
    Hyperactive Member vbud's Avatar
    Join Date
    Jan 2002
    Location
    Mru 20 17S, 57 33E Goal: Get out of the BOX Status: In The Shadows!!! Target Posts: 3,000,000,000
    Posts
    378

    Resolved ***Resolved*** Create instance of object from string name

    hi all,

    I need something that would create an instance of an object from a given string name. The problem I am faced with is that I have to dynamically create an instance of a crystal report object given the name of the report.

    In fact I have a database table that keeps the name of the report object in such a way that I might have a string value, say "crptMyReport"

    Now in my code I need would to retrieve this field value and do something like:

    VB Code:
    1. Dim obj as New ReportDocument = Something.CreateInstance("crptMyReport")

    In fact I have tried to look at TypeDescriptor and ConvertFromString which are from System.ComponentModel but with nothing concrete and working till now. Has anyone ever done this or has an idea on how can this be done?
    All help appreciated.

    thanx.
    Last edited by vbud; Sep 30th, 2004 at 06:55 AM.
    >!v!<
    Free your mind, stop thinking
    http://inspirone.blogspot.com

    Please rate this post if it helped you

  2. #2
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,963
    Hi,

    There have been several discussions on this subject. There are two courses of action:

    1. The function CallByName

    2. Reflection.

    Have a search of this forum on these subjects. An come back with any queries.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  3. #3

    Thread Starter
    Hyperactive Member vbud's Avatar
    Join Date
    Jan 2002
    Location
    Mru 20 17S, 57 33E Goal: Get out of the BOX Status: In The Shadows!!! Target Posts: 3,000,000,000
    Posts
    378

    Got it thanx

    Got it resolved, I guess I was not searching the forum by the correct keyword. I bumped into this thread that you posted some time ago.

    thanx again.
    >!v!<
    Free your mind, stop thinking
    http://inspirone.blogspot.com

    Please rate this post if it helped you

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