C++/Appliation Form | Error textBox1 expected a member name

LazyToxic 21 Reputation points
2021-05-22T19:57:45.117+00:00

Hello, so basically i was using a console application with a HWID lock in it, but then i decided to move into Application form (c++, CLR)
i made my design and everything and then i started coding the textbox, but i ran into a problem..

so basically this code on my console application was working fine :

string license;  
  
cin license;  
  
if (Authenticate(license.c_str(), hwid.c_str()))  
{  
}  

then i tried this on the form application :

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)   
{  
  
	std::string hwid = GetHardwareID();  
	  
	  
	if (Authenticate(textBox1->.c_str(), hwid.c_str()))  
	{  
	}  
	  
}  

But here i am getting an error on the dot.
98777-aa.png
The error says : E0133 | expected a member name.

Well i hope i was clear, if you need any other info just let me know, but yeah i am just stuck at this error for a long time and i haven't found a solution yet..
Hope someone can help me..
Thanks !

Developer technologies C++
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 122.5K Reputation points
    2021-05-22T20:07:55.137+00:00

    Try one of the solutions:

    . . .
    IntPtr t = System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi( textBox1->Text );
    if( Authenticate( (const char*)t.ToPointer( ), hwid.c_str( ) )
    {
       . . .
    }
    System::Runtime::InteropServices::Marshal::FreeHGlobal( t );
    . . .
    

1 additional answer

Sort by: Most helpful
  1. RLWA32 49,536 Reputation points
    2021-05-22T20:09:14.94+00:00

    Looks like your mixing apples and oranges.

    The textBox1 variable is probably an instance of system.windows.forms.textbox and you should be getting the textBox1->Text property which will be a System::String^. The posted code .c_str() is for an unmanaged C++ std::string object and it doesn't belong where it is placed.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.