Click here to Skip to main content
14,930,487 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
if (txtDisplay->Text == "0")
txtDisplay->Text = Numbers->Text;

txtDisplay->Text = txtDisplay->Text + Numbers->Text;

the output error
Identifier "txtDisplay" is undefined

What I have tried:

I havent tried any thing and there is no any reference to this in the internet
Updated 8-Mar-21 19:44pm

1 solution

The message "identified XXX is undefined" is pretty generic, because it's a pretty generic error!

What it is saying is "you tried to use a variable called txtDisplay, but I can't find anything of that name that it might be".
It's like a teacher doing roll call and trying to get "Mike Smith" to respond: he isn't in the room, so they never get a response.
And just like that teacher, the trick is to work out why: have you got the right register (or class in C++)? Did Mike move to a different school, or change his name? Or is he off sick?

Start by finding where you create the TextBox, and look closely at it's name and your code above: C++ is case sensitive, so "txtdisplay" will not match "txtDisplay" or "TxtDisplay", or any of the other combinations of upper and lower case letters - so that's the most likely thing to look for.
Then check your code is in the right class: if the TextBox is in the "About" form, and the code is in the "Main" form, then it's not going to find it!

Sorry, but we can't do any of that for you - we have no access to your code and can't see your screen!
A_aab21 9-Mar-21 3:35am
Thank you soo much i appreciate it
and here is the Textbox if you can assist
Textbox// textBox1
this->textBox1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 15.8961F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
this->textBox1->Location = System::Drawing::Point(12, 12);
this->textBox1->Multiline = true;
this->textBox1->Name = L"textBox1";
this->textBox1->RightToLeft = System::Windows::Forms::RightToLeft::Yes;
this->textBox1->Size = System::Drawing::Size(567, 61);
this->textBox1->TabIndex = 0;
this->textBox1->Text = L"0";
this->textBox1->TextChanged += gcnew System::EventHandler(this, &MyForm::textBox1_TextChanged);
OriginalGriff 9-Mar-21 3:41am
Go back and read what I said.
Is "textBox1" exactly the same as "txtdisplay" or "txtDisplay"?
A_aab21 9-Mar-21 3:45am
sorry dear am still a beginner
No its not the same, so as i understand i can either use textBox1 instead of txtDisplay or change the textbox name to txtDisplay and all will be fine?
OriginalGriff 9-Mar-21 4:18am
Well, I can't guarantee it, but it should certainly improve things ... :D

I'd change the textbox name, so your code becomes more self documenting.
A_aab21 9-Mar-21 11:49am
ALright i have tried again after adjusting and evrything went well,
Thank you sooo much i really appreciate your efforts
OriginalGriff 9-Mar-21 11:50am
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900