1. 程式人生 > >asp.net(C#)寫的九九乘法表有問題,看一看

asp.net(C#)寫的九九乘法表有問題,看一看

 用asp.net(c#)寫的九九乘法表,要求輸入開始值和結束值,我寫的程式程式碼如下:

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnEnter_Click(object sender, EventArgs e)
    {
        if (txtBegin.Text.Trim() == "" || txtEnd.Text.Trim() == "")
        {
            lblMessage.Text = "請輸入完整資訊!";
        }
        else
        {
            for (int i = Convert.ToInt32(txtBegin.Text.Trim()); i <= Convert.ToInt32(txtEnd.Text.Trim()); i++)
            {
                for (int j = 1; j <= i; j++)
                {
                    lblMessage.Text = i + "*" + j + "=" + i * j;

                }
            }
        }
    }
}

txtBegin是開始值的文字框名稱,txtEnd是結束值的文字框名稱,如果在開始值寫1,結束值寫9,程式執行出來,就是9*9=81,不是乘法表的形式,不知道為什麼,哪個高手來看看,多謝了