?
Solved

Dynamically call a class startup

Posted on 2006-11-17
4
Medium Priority
?
170 Views
Last Modified: 2010-04-16
Hi all.  I am pulling in some class names from a INI file.  I need to call the class file startup with that name.  For example, I have account numbers such as XYZ123, ABC555

In my VB code I need to append "cls" to that string such as clsXYZ123 and then call clsXYZ123.Startup

Any help?

I tried dimming an object but no dice
0
Comment
Question by:sbornstein2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 17969253
What VB are you working in here?...

VBScript, VBA, VB6, VB.net 2003 (or below), VB.Net 2005

And what is "Startup"?  Is that a sub/method in the class or are you trying to make the constructor fire?

Give us a bigger picture of what you are doing.
0
 
LVL 16

Assisted Solution

by:AlexNek
AlexNek earned 400 total points
ID: 17974627
an easy solution is to use an If or switch by your init name XYZ123, and crete a class in if or switch case.
0
 

Author Comment

by:sbornstein2
ID: 17979234
working in VB6.0.  Here is the sample code:

Public Sub cmdLogin_Click()
Dim i As Integer
Dim editSplit
Dim strEdit As String
Dim objClass As Object

    editSplit = Split(IUREdits, ",")
    'Run each edit for IUR

    For i = LBound(editSplit) To UBound(editSplit)
        strEdit = Trim(editSplit(i))
       
        'First import all text file data for new week run
        clsImportData.ImportReports (strEdit)
       
        'Next run the corresponding class Startup
        objClass = "cls" & strEdit
        Set objClass = New objClass
        objClass.Startup
       
        'Finally CleanUp Access DB
        clsImportData.CleanUp
    Next
       
End Sub

the strEdit will have what I want to call with "cls"" in front
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 1200 total points
ID: 17981219
I think you would need to use COM to do that type of setup in VB6.  So your classes would need to be ActiveX DLLs...
Then you could use CreateObject():
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/b1545c3f-5cab-4c66-af6f-be9b7daa1131.asp

VB.Net can instantiate objects like that internally using Reflection.

AlexNek has already suggested a big switch...
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Six Sigma Control Plans

764 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