System.StackOverflowException

paulthepaddy

Well-known member
Joined
Apr 9, 2011
Messages
222
Location
UK
Programming Experience
Beginner
hey guys/girls
i have a radiobutton, when checked it populates damage list, and a combobox. when a value is selected form the combobox is calls this code

Call clear_Price() ' tis just clears a few vairables and textboxes
method = DirectCast(ComboBox_Spray.SelectedValue, Action)
method.Invoke()

the action is call Spray_Parking_Sensors() which contains this code

Damage_List.Items.Clear()
Damage_List.Items.Add("Parking Sensors")
Damage_List.SetItemCheckState(0, CheckState.Checked)
Price_Subtotal = 25
Car_Price_Subtotal.Value = Price_Subtotal
Call discount()
the line "Damage_List.Items.Clear()" is giving this error

An unhandled exception of type 'System.StackOverflowException' occurred in System.Windows.Forms.dll

it also says make sure you do not have infinate loop or infinate recursion
 
This happens when a function calls itself over and over again.
The problematic line Damage_List.Items.Clear() triggers the function it is set in.

So, you probably have an event Damage_List.ItemChanged or something to that effect which calls Spray_Parking_Sensors() when any item is changed (Items.Clear() also changes the items). Either move the Clear() order somewhere where it can't be called by the event or add some sort of a flag as to when to do the event.

example:

dim IgnoreItemChanged as boolean = false

sub Spray_Parking_Sensors()
IgnoreItemChanged= true
(Do all of the code above)
IgnoreItemChanged = false


sub Damage_List.ItemChanged
If IgnoreItemChanged then exit sub
call Spray_Parking_Sensors()

hope this helps
 

Similar threads

Back
Top