CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Jan 2010
    Posts
    45

    Question Hot to get text from textbox

    Hi,

    I've been using the following to set text in the textbox:
    this->textBox_PaymentDue->Text = "$50";

    but now I want to retrieve text from the text box.

    I've tried:

    string str;
    str=this->textBox_PaymentDue->Text;

    but this doesn't work. What am I doing wrong?

    Thanks,

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Hot to get text from textbox

    That doesn't look like any kind of VC++ code I've ever seen. What is textBox_PaymentDue?

  3. #3
    Join Date
    Jan 2010
    Posts
    45

    Re: Hot to get text from textbox

    Quote Originally Posted by GCDEF View Post
    That doesn't look like any kind of VC++ code I've ever seen. What is textBox_PaymentDue?
    "textBox_PaymentDue" is just the name that I gave to the
    System.Windows.Forms.Textbox

    as opposed to using the default "textBox1"

  4. #4
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Hot to get text from textbox

    Quote Originally Posted by vc_user View Post
    "textBox_PaymentDue" is just the name that I gave to the
    System.Windows.Forms.Textbox

    as opposed to using the default "textBox1"
    You want to be one of the .net forums.

  5. #5
    Join Date
    Jan 2010
    Posts
    45

    Re: Hot to get text from textbox

    Do you know if VC++ 2010 or 2008 express allows you to make a non net Windows Gui application? It looks like that's the only option.

    Maybe standard edition does?

  6. #6
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: Hot to get text from textbox

    You can make non-.NET GUI apps with the Express Edition, you'd just need to create a Win32 project (not a Win32 Console project) instead of a Windows Forms project. But that would be a really tough endeavour because you would need to work with raw Win32 API. The Express Edition doesn't feature any framework like MFC to support you in this, not even a resource editor.

    There is no such thing as a Standard Edition (see http://msdn.microsoft.com/en-us/library/hs24szh9.aspx). The least you would need to conveniently develop Win32 GUI apps would be the Professional Edition, and unfortunately this isn't really cheap. Or you are lucky to fulfill the prerequisites to get a student edition which AFAIK would be free (see http://www.dreamspark.com).

    But if you are writing .NET apps you should consequently stay inside the .NET world while doing so unless there's a real need to cross the border. E.g. you should use System::String instead of std::string unlike your code snippet from the OP.

    And, well, there's still the option to use one of the non-MS frameworks like Qt. Some of them would even allow you to do cross-platform development. But of course I don't know whether this path really is an option for you.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  7. #7
    Join Date
    Jun 2001
    Location
    USA
    Posts
    298

    Re: Hot to get text from textbox

    You don't say what kind of project it is, but try using UpdateData(FALSE) after writing to the control, and UpdateData(TRUE) before reading it back. At least, that's how I do it with Dialog based apps.

  8. #8
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Hot to get text from textbox

    Quote Originally Posted by Dave C View Post
    You don't say what kind of project it is, but try using UpdateData(FALSE) after writing to the control, and UpdateData(TRUE) before reading it back. At least, that's how I do it with Dialog based apps.
    He's writing a .net app, not MFC with DDX.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured