示例#1
0
        private void BtnMostrar_Click(object sender, EventArgs e)
        {
            if (TxtInicio.Text.Trim().Length == 0)
            {
                MessageBox.Show("INGRESE UN DATO");
                TxtInicio.Focus();
                return;
            }
            if (TxtFinal.Text.Trim().Length == 0)
            {
                MessageBox.Show("INGRESE UN DATO");
                TxtFinal.Focus();
                return;
            }

            int i, nin, nf, rest = 0;

            nin = Convert.ToInt16(TxtInicio.Text);
            nf  = Convert.ToInt16(TxtFinal.Text);


            for (i = nin; i <= nf; i++)
            {
                rest += i;
            }

            TxtRest.Text = rest.ToString();
        }
示例#2
0
 private void button1_Click(object sender, EventArgs e)
 {
     TxtInicio.Clear();
     TxtFinal.Clear();
     TxtRest.Clear();
     TxtInicio.Focus();
 }
示例#3
0
        private void BtnMostrar_Click(object sender, EventArgs e)
        {
            if (TxtInicio.Text.Trim().Length == 0)
            {
                MessageBox.Show("Ingrese un valor");
                TxtInicio.Focus();
                return;
            }
            if (TxtFinal.Text.Trim().Length == 0)
            {
                MessageBox.Show("Ingrese un valor");
                TxtFinal.Focus();
                return;
            }
            int i, ni, nf;

            ni = Convert.ToInt16(TxtInicio.Text.Trim());
            nf = Convert.ToInt16(TxtFinal.Text.Trim());

            for (i = ni; i <= nf; i++)
            {
                TxtMostrar.Text = TxtMostrar.Text + i.ToString() + " ";
            }
        }