inighthawki Posted July 9, 2006 Posted July 9, 2006 i am having some trouble transitioning a few things with C++ from vb, in vb, i could easily grab the text value from a button's sender property by declaring a variable as a control and grabbing it from there Dim c as Control = sender Dim s as string = c.text walla, however, obviously not so easy in C++, it gives me a cannot covert object -> control...anyone know exactly how to go about doing this? Quote
Administrators PlausiblyDamp Posted July 9, 2006 Administrators Posted July 9, 2006 You will need to cast sender to Control, my C++ is a bit rusty but the syntax should be similar to C# Control c = (Control) sender; Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Leaders snarfblam Posted July 9, 2006 Leaders Posted July 9, 2006 (edited) Wouldn't we be dealing with pointers or handles in C++ (depending on the version)? I'd think it would be something more like this: // 7 Control* c = (Control*) sender; System::String* text = c->Text; //or System::String* text = ((Control*)sender)->Text; // 8 Control^ c = (Control^) sender; System::String^ text = c->Text; //or System::String^ text = ((Control^)sender)->Text; Edited July 9, 2006 by snarfblam Quote [sIGPIC]e[/sIGPIC]
inighthawki Posted July 9, 2006 Author Posted July 9, 2006 ah ok thx marble eater, i found a thread b4 with something like what PlausiblyDamp wrote, but it didn't work, that ^ after the Control was the trick to it working. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.