dimanche 25 février 2018

Want to break after if statement, kinda?

So what i am trying to do is test a form textbox for input. Once i click a button, i want it to check if there is any text, if not, i want it to break there and keep prompting a messagebox until the user inputs proper text, and then continue with the program.

if (entryName.Text == "")
        {
            MessageBox.Show("Please enter a name for the entrant");
        }
        if (pickPartner.Text == "")
        {
            MessageBox.Show("Please pick a partner to rope with");
        }
        if (comboBox1.SelectedIndex == -1)
        {
            MessageBox.Show("Please choose a role");
        }
        else
        {
            if(comboBox1.SelectedIndex == 0)
            {
                headerEntries.Add(entryName.Text);                   
                using (StreamWriter writeRopers = new StreamWriter("headers.txt"))
                {
                    writeRopers.WriteLine(entryName.Text);
                }
                using (StreamWriter writeRopers = new StreamWriter("teams.txt"))
                {
                    writeRopers.WriteLine(entryName.Text + " & " + pickPartner.Text);
                }
                    Debug.WriteLine(entryName.Text + " has been added as a header");
                headerCount = headerCount + 1;
                entryName.Clear();
                comboBox1.SelectedIndex = -1;

            }

Aucun commentaire:

Enregistrer un commentaire