Error message in calculator code

I tested the following code and it works fine. Like the comments have said you will get this error if you have not yet created an element with the name txtDisplay. More code would be helpful so I can edit my answer accordingly.

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

    private void btnOne_Click(object sender, EventArgs e)
    {
        txtDisplay.Text += btnOne.Text;
    }
}

Leave a Comment