Hello, I wanna create a string witch gets the value of a textbox. How can I make it ? THX for your replays :D

what operating system, what gui, what compiler ??? We need a whole lot more information that what you have provided.

So Visual C++ on Windows 7.

I'm not in the mood for playing guessing games today, so I'll pass on this one.

Haha.
Where is the textbox?
Is it a listbox, combobox or an edit control?
Using wxwidgets, mfc, atl, winapi or what?

The guessing game continues..

All you need is a system string, not a string. This procedure copies text from textBox to string and viceversa.

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
             String ^ strTextBoxContent;
             strTextBoxContent = textBox1->Text;
             textBox2->Text=strTextBoxContent;

         }

Taste of wxWidgets

wxTextCtrl* texfromuser = new wxTextCtrl(this, wxID_ANY);
wxString testText = textfromuser->GetValue();
wxMessageBox(testText, wxT("User Text"));

Winapi, if there is a window (hwnd) that has a child Edit control with ID 1:

HWND hwnd_edit = GetDlgItem(hwnd, 1);
size_t len = GetWindowTextLength(hwnd_edit);
if(len){
  char *buffer = new char[len+2];
  GetWindowText(hwnd_edit, buffer, len+1);
  buffer[len+1] = '\0';
  //And if it must be a string:
  std::string YourString(buffer);
  delete[] buffer;
}

Thanck u so mutch !!! it work :D THX THX THX :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.