Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable Object Instantiation

Status
Not open for further replies.

whornak

Programmer
Joined
Aug 12, 2005
Messages
2
Location
US
How do I instantiate a Crystal Report or any other object when the name of the object is stored in a variable?
 
See these FAQ's, maybe they will help you. Good Luck!

Get control by name using reflection faq796-5698
Get Form by Name faq796-6037

Have a great day!

j2consulting@yahoo.com
 
BTW SBendBuckeye, I got it to work this way

Code:
Private Function GetFormByName(ByVal formName As String) As Object
        Dim myasm As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly()
        Try
            Return myasm.CreateInstance(myasm.GetName.Name.Replace(" ", "_") & "." & formName)
        Catch ex As Exception
            Return Nothing
        End Try
    End Function

Christiaan Baes
Belgium

I just like this --> [Wiggle] [Wiggle]
 
Thanks Chrissie1! I'll update my FAQ, giving you your rightful props of course.

Have a great day!

j2consulting@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top