ถาม C# Windows Form เกมผลัดกันนับเลขครับ

เขียนเกม นับ 1 - 20
http://mathminton.blogspot.com/2011/07/count-game.html
private void button1_Click(object sender, EventArgs e)
{
        string total = "";
        string t = "";
        int sum;

        if (s.Length == 1)
        {
                t = s.Substring(0, 1);
                for (int i = 1; i <= 3; i++)
                {
                        int j = int.Parse(t);
                        sum = j + i;
                        total += sum.ToString() + "";
                        if (sum == 20)
                        {
                                MessageBox.Show("You Lose");
                                break;
                        }
                }
                textBox2.Text = total;
        }
        else if (s.Length == 3)
        {
                t = s.Substring(2, 1);
                for (int i = 1; i <= 2; i++)
                {
                        int j = int.Parse(t);
                        sum = j + i;
                        total += sum.ToString() + "";
                        if (sum == 20)
                        {
                                MessageBox.Show("You Lose");
                                break;
                        }
                }
                textBox2.Text = total;
        }
        else if (s.Length == 5)
        {
                t = s.Substring(4, 1);
                for (int i = 1; i <= 1; i++)
                {
                        int j = int.Parse(t);
                        sum = j + i;
                        total += sum.ToString() + "";
                        if(sum == 20)
                        {
                                MessageBox.Show("You Lose");
                                break;
                        }
                }
                textBox2.Text = total;
        }
        else
                MessageBox.Show("Again Number");
                textBox1.Clear();
                textBox1.Focus();
        }
}
แก้ไขข้อความเมื่อ
แสดงความคิดเห็น
โปรดศึกษาและยอมรับนโยบายข้อมูลส่วนบุคคลก่อนเริ่มใช้งาน อ่านเพิ่มเติมได้ที่นี่