Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This C# program is a times table. The first number of the range goes in the first box, the last number of the range goes

This C# program is a times table. The first number of the range goes in the first box, the last number of the range goes in the second box, and the third box is the number I'm multiplying by. That part works, but I'm having a hard time with the loop for the blank boxes. It gives me the message "Type numbers in the text boxes" when I type a number in the first box. I think I'm supposed to type something after else...

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data; using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

namespace TimesTable

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

int answer = 0;

int loopStart;

int loopEnd;

int multiplyBy = 10;

loopStart = int.Parse(textBox1.Text);

loopEnd = int.Parse(textBox2.Text);

multiplyBy = int.Parse(textBox3.Text);

listBox1.Items.Clear();

for (int i = loopStart; i < loopEnd; i++)

while (i <= loopEnd)

{

answer = multiplyBy * i;

listBox1.Items.Add(i + "times" + multiplyBy + "=" + answer.ToString());

i++;

}

}

private void textBox1_TextChanged(object sender, EventArgs e)

{

int outputValue = 0;

bool isNumber = false;

isNumber = int.TryParse(textBox1.Text, out outputValue);

isNumber = int.TryParse(textBox2.Text, out outputValue);

isNumber = int.TryParse(textBox3.Text, out outputValue);

if (!isNumber)

{ MessageBox.Show("Type numbers in the text boxes");

}

else

{

}

}

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions