Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello all

I think I am close to finishing this project but I am getting a "lare binding" error and can't seem to resolve it - HELP?

 

 

 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

Posted

There seems to be a confusion between collections of cars and individual cars. What does the MyCarLIst contain?

Doing;

myCarList = myCarList(index)

This seems incorrect. I think you need a new variables here, something like:

 

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

 

I wouldn't 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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...