Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Do...While not functioning as expected.

$
0
0

Here is my code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Assignment5Part4
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void calcLoop_Click_1(object sender, EventArgs e)
        {
            int answer = 0;
            int j = int.Parse(loopEnd.Text);
            int multiplyBy = int.Parse(multiplier.Text);
            int i = int.Parse(loopStart.Text);
            do
            {
                answer = multiplyBy * i;
                listBox1.Items.Add(i + "  times " + multiplyBy + " =  " + answer.ToString());
                i++;
            }
            while (i <= j);
            while (j <= 10); 
        }

        private void exitButton_Click(object sender, EventArgs e)
        {
            this.Close(); //exit the program
        }
    }
}

Here is my GUI:

Now, when I enter 45 for loop start, 169 for loop end, and 3 for multiplier, it works. However, when I enter 0 as loop start, 10 for loop end, and 3 for multiplier, it does not work, and no error codes are given. It just freezes. What am I doing wrong?

Thank you.


Mitch Hean


Viewing all articles
Browse latest Browse all 31927

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>