private void removeEloFromCheckBoxString() { int countTeam = sql.count("teams3v3", "id", ""); try { string p1 = ""; string p2 = ""; string p3 = ""; foreach (string s in playerListBox.CheckedItems) { string removedElo = ""; if (s.Contains(" ")) { removedElo = s.Substring(s.IndexOf(" ") + 3); } else { removedElo = s.Substring(s.IndexOf(" ") + 1); } if (p1 == "") { p1 = removedElo; } else if (p2 == "") { p2 = removedElo; } else if (p3 == "") { p3 = removedElo; } } sql.add3v3Team(countTeam, teamNameBox.Text, coachNameBox.Text, p1, p2, p3); } catch { errorLabel.Text = "Team name already exists"; errorLabel.Location = new Point((ActiveForm.Width - errorLabel.Width) / 2, 465); addingLabel.Text = ""; } errorLabel.Text = "Team successfully added"; errorLabel.Location = new Point((ActiveForm.Width - errorLabel.Width) / 2, 465); addingLabel.Text = ""; }