paulthepaddy
Well-known member
System.NullReferenceException was unhandled
Message=Object reference not set to an instance of an object.
Source=Image Invoice Management
StackTrace:
at Image_Invoice_Management.Form_Invoice_Management.SSR_Scratches(CheckedItemCollection Damage, car SelectCar) in C:\Users\Paul\Documents\VB Stuff\Projects\Image Invoice Management b test Object List\Image Invoice Management\Invoice Managment.vb:line 858
at Image_Invoice_Management.Form_Invoice_Management.BTN_Add_Damage_Click(Object sender, EventArgs e) in C:\Users\Paul\Documents\VB Stuff\Projects\Image Invoice Management b test Object List\Image Invoice Management\Invoice Managment.vb:line 600
`
hey guys this is the error im getting and this is what is causing it i have colour coded it so it is easier to read... i hope
i Dont understand why this is giving an error i call the sub using this
the ComboBox_Current_Car.SelectedItem contains a BindingList(Of car) = New BindingList(Of car)
i do understand that the list count is 0 so shouldn't it be declairing Start_Pos = 0
thanks for any advice in advanced and if any1 knows of a better way to write the sub please do inform
Message=Object reference not set to an instance of an object.
Source=Image Invoice Management
StackTrace:
at Image_Invoice_Management.Form_Invoice_Management.SSR_Scratches(CheckedItemCollection Damage, car SelectCar) in C:\Users\Paul\Documents\VB Stuff\Projects\Image Invoice Management b test Object List\Image Invoice Management\Invoice Managment.vb:line 858
at Image_Invoice_Management.Form_Invoice_Management.BTN_Add_Damage_Click(Object sender, EventArgs e) in C:\Users\Paul\Documents\VB Stuff\Projects\Image Invoice Management b test Object List\Image Invoice Management\Invoice Managment.vb:line 600
`
hey guys this is the error im getting and this is what is causing it i have colour coded it so it is easier to read... i hope
VB.NET:
[COLOR=#0000ff]Public Sub[/COLOR] SSR_Scratches(Damage [COLOR=#0000ff]As[/COLOR] [COLOR=#40e0d0]CheckedListBox.CheckedItemCollection[/COLOR], SelectCar [COLOR=#0000ff]As[/COLOR] [COLOR=#40e0d0]car[/COLOR])
Car_Damage_Type = [COLOR=#ff0000]"Repair Scratches on "[/COLOR]
[COLOR=#0000ff]Dim[/COLOR] Start_Pos [COLOR=#0000ff]As[/COLOR] Integer = SelectCar.SSR_ScratchDamage.Count[COLOR=#008000]' Error Here[/COLOR]
[COLOR=#008000]'Cases If only Adding 1 Item To Damagelist[/COLOR]
[COLOR=#0000ff]Select Case[/COLOR] Damage.Count
[COLOR=#008000] 'Case For adding 1 Item into an Empty List[/COLOR]
[COLOR=#0000ff]Case Is[/COLOR] = 1
[COLOR=#0000ff]Select Case[/COLOR] SelectCar.SSR_ScratchDamage.Count
[COLOR=#0000ff]Case Is[/COLOR] = 0
SelectCar.SSR_ScratchDamage(Start_Pos) = Car_Damage_Type & Damage.Item(0)
SelectCar.Subtotal += 25
[COLOR=#008000] 'Case For adding 1 Item into a NON Empty List[/COLOR]
[COLOR=#0000ff] Case Is[/COLOR] >= 1
[COLOR=#0000ff]If Not[/COLOR] SelectCar.SSR_ScratchDamage.Contains(Damage.Item(0)) [COLOR=#0000ff]Then[/COLOR]
SelectCar.SSR_ScratchDamage(Start_Pos) = Damage.Item(0)
SelectCar.Subtotal += 15
[COLOR=#0000ff] End If
End Select[/COLOR]
[COLOR=#008000] 'Cases For Adding More Than 1 Item To Damagelist[/COLOR]
[COLOR=#0000ff]Case Is >= 2[/COLOR]
[COLOR=#0000ff]Select Case[/COLOR] SelectCar.SSR_ScratchDamage.Count
[COLOR=#008000]'Case For Adding Multiple Items Into a Emply List[/COLOR]
[COLOR=#0000ff]Case Is[/COLOR] = 0
SelectCar.SSR_ScratchDamage(Start_Pos) = Car_Damage_Type & Damage.Item(0)
[COLOR=#0000ff]For[/COLOR] i = 1 To Damage.Count - 1
[COLOR=#0000ff] If Not[/COLOR] SelectCar.SSR_ScratchDamage.Contains(Damage.Item(i)) [COLOR=#0000ff]Then[/COLOR]
SelectCar.SSR_ScratchDamage(Start_Pos) = Damage.Item(i)
Start_Pos = Start_Pos + 1
[COLOR=#0000ff] End If
Next[/COLOR]
SelectCar.Subtotal += ((Damage.Count * 15) + 10)
[COLOR=#008000] 'case For Adding Multiple Item into a Non Empty List[/COLOR]
[COLOR=#0000ff]Case Is[/COLOR] >= 1
[COLOR=#0000ff]For[/COLOR] i = 0 To Damage.Count - 1
[COLOR=#0000ff] If Not[/COLOR] SelectCar.SSR_ScratchDamage.Contains(Damage.Item(i)) [COLOR=#0000ff]Then[/COLOR]
SelectCar.SSR_ScratchDamage(Start_Pos) = Damage.Item(i)
Start_Pos = Start_Pos + 1
[COLOR=#0000ff]End If
Next[/COLOR]
SelectCar.Subtotal += ((Damage.Count * 15) + 10)
[COLOR=#0000ff]End Select
End Select
For Each[/COLOR] item [COLOR=#0000ff]In[/COLOR] SelectCar.SSR_ScratchDamage
CheckedListBox_Car.Items.Add(item)
[COLOR=#0000ff]Next
End Sub[/COLOR]
i Dont understand why this is giving an error i call the sub using this
VB.NET:
Call SSR_Scratches(Damage_List.CheckedItems, ComboBox_Current_Car.SelectedItem)
the ComboBox_Current_Car.SelectedItem contains a BindingList(Of car) = New BindingList(Of car)
i do understand that the list count is 0 so shouldn't it be declairing Start_Pos = 0
thanks for any advice in advanced and if any1 knows of a better way to write the sub please do inform