/* FEATURES: This beauty shows how to create a two control arrays for baseball scores. We create an array of labels for each team. Then we create two arrays of scores. Using a loop, we simply copy each run scores into the corresponding label on the form. It also shows how to loop through an array to get a total runs scored for each team */ private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) { //lets make a two "control arrays" for the visitors labels and home team labels. // Remember these are indexed starting at 0. array^ VisitorsInnings = {V1,V2, V3,V4,V5,V6,V7,V8,V9}; //our actual label names array^ HomeInnings = {H1,H2, H3,H4,H5,H6,H7,H8,H9}; //---create two arrays to hold runs scored per inning array^ VisitorsRuns= gcnew array{0,2,2,1,0,1,0,1,1}; array^ HomeTeamRuns =gcnew array {2,0,1,0,2,1,0,0,4}; //runs per inning //---we need total scores int VTotalRuns = 0; int HTotalRuns = 0; //---now cycle through each label and copy the runs scored into the text property for(int x=0; x<9;x++) { VisitorsInnings[x]->Text = VisitorsRuns[x].ToString(); VTotalRuns += VisitorsRuns[x]; HomeInnings[x]->Text = HomeTeamRuns[x].ToString(); HTotalRuns += HomeTeamRuns[x]; } //---display total scores here VRuns->Text = VTotalRuns.ToString(); HRuns->Text = HTotalRuns.ToString(); }