Re: Dynamically calling classes and properties

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



What is it that you are using this for?

I suspect that, as in most cases when someone asks for dynamic variables, it can be solved in a different way.

wisaunders@xxxxxxxxx wrote:
I have several different classes that contain the same four
properties. I tell my application property of which class to call in
the configuration file.

Here are the values from my config file

<class>AAAA</class>
<property>1111</property>


This is how I current have it working.

Dim sql As String = ""
Select Case classVariable
Case "AAAA"
Dim extract As New AAAA
Select Case propertyVariable
Case "1111"
sql = extract.1111
Case "2222"
sql = extract.2222
Case "3333"
sql = extract.3333
Case "4444"
sql = extract.4444
Case Else
'quit function
End Select
Case "BBBB"
Dim extract As New BBBB
Select Case propertyVariable
Case "1111"
sql = extract.1111
Case "2222"
sql = extract.2222
Case "3333"
sql = extract.3333
Case "4444"
sql = extract.4444
Case Else
'quit function
End Select
Case "CCCC"
Dim extract As New CCCC
Select Case propertyVariable
Case "1111"
sql = extract.1111
Case "2222"
sql = extract.2222
Case "3333"
sql = extract.3333
Case "4444"
sql = extract.4444
Case Else
'quit function
End Select
End Select

Is there a was to call these classes and properties dynamically with
variable from my config file.
Something that looks like this? I don't want to have to add another
case and select case for every new class.

Dim extract as new [classVariable]
Sql = extract.[propertyVariable]

Thanks in advance,
Will



--
Göran Andersson
_____
http://www.guffa.com
.



Relevant Pages

  • Re: Dynamically calling classes and properties
    ... so you can use a string to convert it to ... Dim sql As String = "" ... Dim extract As New AAAA ...
    (microsoft.public.dotnet.languages.vb)
  • Dynamically calling classes and properties
    ... Here are the values from my config file ... Dim sql As String = "" ... Dim extract As New AAAA ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Dynamically calling classes and properties
    ... Here are the values from my config file ... Dim sql As String = "" ... Dim extract As New AAAA ... An alternative is to create an interface with those 4 methods and have each class "Implement" the interface. ...
    (microsoft.public.dotnet.languages.vb)