create/use array of different classes?
From: Ron (anonymous_at_discussions.microsoft.com)
Date: 10/07/04
- Next message: Iain Mcleod: "Re: Counter Strike blocker?"
- Previous message: Johan Christensson: "Re: Counter Strike blocker?"
- In reply to: Ron: "create/use array of different classes?"
- Next in thread: Imran Koradia: "Re: create/use array of different classes?"
- Reply: Imran Koradia: "Re: create/use array of different classes?"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 7 Oct 2004 14:29:58 -0700
Well, I came up with one solution that isn't real dynamic,
but it seems to work:
For i As Integer = 1 to dts.Length
If i = 1 Then Ctype(dts(i), clsDTS1).DataPath = strPath(i)
If i = 2 Then Ctype(dts(i), clsDTS2).DataPath = strPath(i)
If i = 3 Then Ctype(dts(i), clsDTS3).DataPath = strPath(i)
If i = 4 Then Ctype(dts(i), clsDTS4).DataPath = strPath(i)
...
Any suggestions appreciated if there is a better way.
>-----Original Message-----
>Hello,
>
>I have 4 classes that use 4 DTS packages on 4 different
>tables. So I have
>Dim cls1 As New clsDTS1, cls2 As New clsDTS2
>Dim cls3 As New clsDTS3, cls4 As New clsDTS4
>
>Each class has a common property called DataPath
>cls1.DataPath = strPath
>
>I want to use these classes in a loop, so I need to put
>them in some kind of array. Obviously I can't use a
class
>array because they are all different classes. So I tried
>using an object array like this:
>
>Dim dts() As Object = {cls1, cls2, cls3, cls4}
>For i As Integer = 0 To dts.Length - 1
> Ctype(dts(i), dts(i)).DataPath = strPath(i)
>....
>
>I had a problem with Ctype(dts(i), dts(i)) where the
>compiler said it needed a type for the 2nd dts(i), so I
am
>kind of in an infinite loop here. Could anyone suggest
>what kind of collection object/structure I could use to
>loop through the 4 different classes?
>
>Thanks,
>Ron
>.
>
- Next message: Iain Mcleod: "Re: Counter Strike blocker?"
- Previous message: Johan Christensson: "Re: Counter Strike blocker?"
- In reply to: Ron: "create/use array of different classes?"
- Next in thread: Imran Koradia: "Re: create/use array of different classes?"
- Reply: Imran Koradia: "Re: create/use array of different classes?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|