Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 134
  • Last Modified:

Dynamically create object determined at runtime

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:
Report1.rpt
Report2.rpt
Report3.rpt
Report4.rpt

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)
0
pdraigh
Asked:
pdraigh
  • 4
1 Solution
 
Mikal613Commented:
can you be more specific?

If the value is 2 then you wanna create Report2?
0
 
pdraighAuthor Commented:
Correct.  I want to create the correct report object based on the value of my string without using a big long if...elseif...elseif.  
0
 
Mikal613Commented:
your gonna have to do a select case and run it as that
0
 
Mikal613Commented:
callbyname good answer
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now