Dynamically create object determined at runtime

Posted on 2004-11-04
Last Modified: 2010-04-23
I have an application with a bunch of crystal reports.  Is it possible to dynamically create my report object from one of several reports?

Something like

Reports in the project:

Usually, I do this:
Dim rptTest As Report1
rptTest = New Report1

But, can I do something like this?

dim strReport as string = "Report3"   'or retrieved from the database, etc.
dim rptTest as (something determined by the value of strReport)
rptTest = New (that thing determined by the value of strReport)
Question by:pdraigh
    LVL 48

    Expert Comment

    can you be more specific?

    If the value is 2 then you wanna create Report2?

    Author Comment

    Correct.  I want to create the correct report object based on the value of my string without using a big long if...elseif...elseif.  
    LVL 48

    Accepted Solution

    your gonna have to do a select case and run it as that
    LVL 48

    Expert Comment

    LVL 48

    Expert Comment

    callbyname good answer

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
    A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now