How to fetch information from textBox in MessageBox

Hi,
I am playing with the c++ windows application forms

and what i am trying to accomplish is this:

1
2
3
4
5
6
7
8
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) 
					 {
						 MessageBox::Show(
						 "Info entered:\n"
						 "Text 1: " << k1->Text //k1 is textBox

						 );
					 }


but i get the following error:
error C2677: binary '<<' : no global operator found which takes type 'System::String ^' (or there is no acceptable conversion)


thanks
Last edited on
WoW - THANKS great support, i am speechless!!
.... ... ...
Sarcasm?

Excellent. My willingness to help you has completely depleted given that you waited less than four hours to shoot down people in this forum.

Good luck.
4 hours are very relative thing mate.. don't you think that? .. no fun at all! but frustrations to get stuck on such a funny-simple problem
I agree, four hours are a very relative thing. Especially when people have full time professions and only answer queries during their own free time.
so this may be a stupid question, but did you include <string> and <iostream> in your header and your class files?

The error message is saying it doesn't recognize the "<<" in your program.

I haven't been coding in c++ long, but can you use << in a function without cout?
indeed i din't think of that ..
i included string and iostream and now i get the following compile error messages:
1>c:\users\developer\documents\visual studio 2010\projects\over again\sportlife1\sportlife1\Form1.h(482): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'const char [9]'
1>          c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\string(489) : see declaration of 'std::operator <<'
1>c:\users\developer\documents\visual studio 2010\projects\over again\sportlife1\sportlife1\Form1.h(482): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const std::error_code &)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'const char [9]'
1>          c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ostream(1085) : see declaration of 'std::operator <<'
1>c:\users\developer\documents\visual studio 2010\projects\over again\sportlife1\sportlife1\Form1.h(482): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &&,_Ty)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &&' from 'const char [9]'
1>          c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ostream(968) : see declaration of 'std::operator <<'
1>c:\users\developer\documents\visual studio 2010\projects\over again\sportlife1\sportlife1\Form1.h(482): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,unsigned char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'const char [9]'
1>          c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ostream(958) : see declaration of 'std::operator <<'
1>c:\users\developer\documents\visual studio 2010\projects\over again\sportlife1\sportlife1\Form1.h(482): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const unsigned char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'const char [9]'
1>          c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ostream(951) : see declaration of 'std::operator <<'
1>c:\users\developer\documents\visual studio 2010\projects\over again\sportlife1\sportlife1\Form1.h(482): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,signed char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'const char [9]'
1>          c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ostream(944) : see declaration of 'std::operator <<'
1>c:\users\developer\documents\visual studio 2010\projects\over again\sportlife1\sportlife1\Form1.h(482): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const signed char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'const char [9]'
1>          c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ostream(937) : see declaration of 'std::operator <<'
1>c:\users\developer\documents\visual studio 2010\projects\over again\sportlife1\sportlife1\Form1.h(482): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,_Elem)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'const char [9]'
1>          c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ostream(898) : see declaration of 'std::operator <<'
1>c:\users\developer\documents\visual studio 2010\projects\over again\sportlife1\sportlife1\Form1.h(482): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const _Elem *)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'const char [9]'
1>          c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ostream(851) : see declaration of 'std::operator <<'
1>c:\users\developer\documents\visual studio 2010\projects\over again\sportlife1\sportlife1\Form1.h(482): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'const char [9]'
1>          c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ostream(811) : see declaration of 'std::operator <<'
1>c:\users\developer\documents\visual studio 2010\projects\over again\sportlife1\sportlife1\Form1.h(482): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'const char [9]'
1>          c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ostream(764) : see declaration of 'std::operator <<'
1>c:\users\developer\documents\visual studio 2010\projects\over again\sportlife1\sportlife1\Form1.h(482): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,char)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'const char [9]'
1>          c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ostream(726) : see declaration of 'std::operator <<'
1>c:\users\developer\documents\visual studio 2010\projects\over again\sportlife1\sportlife1\Form1.h(482): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const char *)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'const char [9]'
1>          c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ostream(679) : see declaration of 'std::operator <<'
1>c:\users\developer\documents\visual studio 2010\projects\over again\sportlife1\sportlife1\Form1.h(482): error C2677: binary '<<' : no global operator found which takes type 'System::String ^' (or there is no acceptable conversion)
1>c:\users\developer\documents\visual studio 2010\projects\over again\sportlife1\sportlife1\Form1.h(482): error C2143: syntax error : missing ')' before ';'
1>c:\users\developer\documents\visual studio 2010\projects\over again\sportlife1\sportlife1\Form1.h(482): error C2059: syntax error : ')'
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.91
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


and really i don't know any other way what to use instead of << (i was wondering the same but.. )
Last edited on
Also having the same problem..what could be wrong?
You don't have to extract anything. The text in the field is a property of the field already. Check out MSDN member functions for a message box.
Your code is C++/CLI, not C++. Yes, they are different. Yes, they can be mixed. Do I know how? No, and most of the regulars of this forum don't either.

So post your questions (and optionally, your sarcasm) in the Microsoft's MSDN forums.
Topic archived. No new replies allowed.