Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with C++ please

Status
Not open for further replies.

traxxas

Programmer
Dec 11, 2003
15
US
hey i just moved over from visual basic too c++ and im making a little prog to see what i can do, in a portion of my progr i want the user to enter the word "press" and press the button next to it and then the textbox would say "pressed"

in vb the code would be:

If text1.text = "press" then text1.text = "pressed"

now, in C++ i put in this code:

if(textBox5->Text == "press")
{
textBox5->set_Text("pressed")
}

but that doesnt work, it compiles but doesnt work in the program, please help if possibal, thanks guys

note: im using C++ .net 2003, and this is a win32 app, NOT a console app
 
First of all, is textBox5 a pointer to a class? Next, where is the debugger saying the error is at? The code you posted looks all right to me if the class members are good and textBox5 is a pointer to a class.

-Bones
 
i get no error, it just doesnt do anything, i heard somewere that the == is the problem but i dont know and textBox5 is a textbox and ->Text is the value that is being looked at
 
this "could" be right. post your codes, and the testBox5 class. In order for the above code to work, your class:

1. needs to have member variable Text public.
2. need to properly overload the == operator
3. textBox5 needs to be a pointer to the class
 
is it possibal i can get a sample of the correct way to do this code

again heres the code i have:

private: System::Void button9_Click(System::Object * sender, System::EventArgs * e)
if(textBox5->Text == "press")
{
textBox5->set_Text("pressed")
}
 
one more question, how do i show a new form when i click a button, i added a new form to my progect (form2) and i want the user to click the button and the form would show, the code would go here

private: System::Void button10_Click(System::Object * sender, System::EventArgs * e)
{
//code goes here
}

but what code summons the form?, thanks for your help guys
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top