VC++窗体应用程序(非MFC),自定义函数中获取textBox内容
VC++建立了个窗体应用程序,窗体上放了一个textBox
按钮函数中能得到textBox内容,
自定义函数中如何得到呢?
代码如下:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
System::String ^s1=textBox1->Text;
char *p1=(char*)(void*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(s1);
}
void ttt(char * charin)
{
System::String ^s2=textBox1->Text;
char *p2=(char*)(void*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(s2);
}
错误提示:
1>c:\users\administrator\desktop\c++\test\test\Form1.h(146): error C2065: “textBox1”: 未声明的标识符
1>c:\users\administrator\desktop\c++\test\test\Form1.h(146): error C2227: “->Text”的左边必须指向类/结构/联合/泛型类型