- Home /
This question was
closed Feb 25, 2015 at 12:37 AM by
Landern for the following reason:
This is a Unity Related site, your question is for WinForm
Question by
jewlsbuddy · Feb 25, 2015 at 12:32 AM ·
multiply
How do you multiply from an array using GUI
I'm trying to create this GUI program using C#. It has an array that contains the numbers 2 through 10. The program is supposed to allow the user to input a number and the program should show the products of all the numbers in the array times the users number. I'm really quite stumped.
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 MultiplicationGUI
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int[] TimesTable = { 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int number = Convert.ToInt32(textBox1.Text);
int answer = Convert.ToInt32(label2);
answer = number * TimesTable[0];
label2.Text = "The products are" + answer;
}
}
}
Comment
please only post Unity related questions, stackoverflow could be a better posting place, but they would probably scream at you.
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int[] TimesTable = { 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int number = Convert.ToInt32(textBox1.Text);
int answer = Convert.ToInt32(label2);
foreach (int multiple in TimesTable)
answer += " " + (number * multiple) + ",";
answer.TrimEnd(',');
label2.Text = "The products are" + answer;
}
Follow this Question
Related Questions
Simple math always returns 0 1 Answer
Pre-multiplied alpha texture 0 Answers
Calculation error when multiplying a float 1 Answer
Error message: "Unexpected token *" javascript - wha? 1 Answer