I keep getting an error on the line that states int userIN = int.Parse(answerBox.Text); I don't see why this is happening. I'm sure it just something I'm overlooking, but I've been sitting here totally baffled.
An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll
Additional information: Input string was not in a correct format.
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 RandomAddition
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// First Random Nummber
int rand1;
Random rn1 = new Random();
rand1 = rn1.Next(500) + 100;
number1.Text = rand1.ToString();
//Second Random Number
int rand2;
rand2 = rn1.Next(500) + 100;
number2.Text = rand2.ToString();
// Answer
int anw = rand1 + rand2;
int answ = rand1 + rand2;
// Check
int userIN = int.Parse(answerBox.Text);
if (answ == userIN)
{
feedback.Text = "Correct";
}
else
{
feedback.Text = "incorrect";
}
}
}
}
Aucun commentaire:
Enregistrer un commentaire