late binding problem - HELP?!

BlueOysterCult

Well-known member
Joined
Oct 3, 2003
Messages
84
Hello all
I think I am close to finishing this project but I am getting a "lare binding" error and cant seem to resolve it - HELP?


Code:
  Dim myCarList As Object
        Dim index As Integer
        Dim basicCarList As BasicVehicle
        Dim luxuryCarList As LuxuryVehicle
        index = cmbCarList.SelectedIndex
        myCarList = myCarList(index)
        If TypeOf (myCarList(index)) Is LuxuryVehicle Then
            luxuryCarList = CType(myCarList, LuxuryVehicle)
            txtYear.Text = CStr(luxuryCarList.Year)
            txtMake.Text = luxuryCarList.Make
            txtModel.Text = luxuryCarList.Model
            txtExtColor.Text = luxuryCarList.ExteriorColor
            txtIntColor.Text = luxuryCarList.InteriorColor
            txtSold.Text = CType(luxuryCarList.Sold, LuxuryVehicle)
        ElseIf (TypeOf (myCarList(index)) Is BasicVehicle) Then
            basicCarList = CType(myCarList, BasicVehicle)
            txtYear.Text = CStr(basicCarList.Year)
            txtMake.Text = basicCarList.Make
            txtModel.Text = basicCarList.Model
            txtExtColor.Text = basicCarList.ExteriorColor
            txtIntColor.Text = basicCarList.InteriorColor

        End If



    End Sub

Rob
 
There seems to be a confusion between collections of cars and individual cars. What does the MyCarLIst contain?
Doing;
Code:
myCarList = myCarList(index)
This seems incorrect. I think you need a new variables here, something like:

Code:
Dim selectedCar as object
selectedCar = myCarList(index)
...

I wouldnt recommend storing your cars stored in an object. Perhaps you could create a abstract base class for your cars, which basicCar and luxuryCar could inherit. This may make things a bit simpler.
 
Back
Top