the numbers in the listbox were added from the textbox.
after the numbers added, I want to summing the numbers in the listbox.
I've made this code but It didn't work:
I got this error:Code:private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) { int i,jum, x, y; { listBox2->Items->Add(txt_add->Text); } x=listBox2->Items->Count; for(i=0; i<=x; i++) { y = Convert::ToInt32(listBox2->Items->Item[i]); //ERROR LINE jum += y; } txt_total2->Text=jum.ToString(); }
can you tell me what's wrong with that code, and what is the right code to solve my case?Code:error C3293: 'Item': use 'default' to access the default property (indexer) for class 'System::Windows::Forms::ListBox::ObjectCollection'




Reply With Quote