Thread: Textbox

  1. #1
    Registered User
    Join Date
    Jul 2005
    Posts
    13

    Textbox

    Hi, I´m newby programming with windows forms. I want to read the text that it is written in a text box, and save it into a char array. I´ve tried a lot of ways to do it, but no one has been the correct. The last one that I´ve tried is:
    Code:
    private: System::Void button1_Click(System::Object *  sender, System::EventArgs *  e)
    			 {
    				 char text[255];
    				 text=(textBox1->Text);
    			 }
    Can anyone help me?

    Thanks,

  2. #2
    Rabite SirCrono6's Avatar
    Join Date
    Nov 2003
    Location
    California, US
    Posts
    269
    If you're on Windows, have you tried

    Code:
    #include <windows.h>
    
    ...
    
    MessageBox( NULL, "Text", "Title", MB_OK );
    ?

    - SirCrono6
    From C to shining C++!

    Great graphics, sounds, algorithms, AI, pathfinding, visual effects, cutscenes, etc., etc. do NOT make a good game.
    - Bubba

    IDE and Compiler - Code::Blocks with MinGW
    Operating System - Windows XP Professional x64 Edition

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    2,663
    Post your question in the "windows programming" forum. When your programs create windows, then you are doing what's called "windows programming", which can be likened to advanced C++.

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    > char text[255];
    > text=(textBox1->Text);
    Have you tried:
    Code:
    				 char text[255];
    				 strcpy( text, textBox1->Text );
    Be sure to include <cstring>

  5. #5
    yes, I'm registered!!! algi's Avatar
    Join Date
    Nov 2004
    Location
    Ipswich
    Posts
    161
    should it be done like
    Code:
    private: System::Void button1_Click(System::Object *  sender, System::EventArgs *  e)
    			 {
    				 char text[255];
    				 text=(this->textBox1->Text);
    			 }
    I started out with nothing and I still have most of it left.

  6. #6
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    Is there a special reason you need a char array ?

    If you are doing Managed C++ ( which I would only suggest if you have to interface with normal C++ and/or write wrapper classes for existing C++ functionality ) then use the System::String* type to hold and manipulate strings. Casting it back and forth between UNICODE enabled System::String* that your TextBox uses and normal char arrays is a pain and not worth the work I guess.

    If you really need a char array, post an example where you need it, I will suggest a means of converting.

    If you are doing .NET, I can only encourage you to look into C#. It's way cleaner and less work than Managed C++.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  7. #7
    Registered User
    Join Date
    Jul 2005
    Posts
    13
    None of the codes worked.

    SirCrono66, thanks for your help, but that is not what I am looking for. I don´t want to open a new windows with text, I just need to save a text form a textbox to an array.


    nvoigt, I don´t need to use an array char, but it is the only way I know to do it, because I don´t know how to use String in C++.

    Thanks,

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 04-02-2009, 04:40 AM
  2. Replies: 5
    Last Post: 03-02-2009, 08:33 AM
  3. Problem with a multiline textbox
    By Zeokat in forum C# Programming
    Replies: 4
    Last Post: 10-24-2008, 01:14 PM
  4. inserting text in a textbox
    By Rune Hunter in forum C# Programming
    Replies: 1
    Last Post: 01-07-2006, 05:32 PM
  5. How would I add a textbox?
    By -KEN- in forum C# Programming
    Replies: 2
    Last Post: 11-13-2001, 02:02 PM