Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

System::String^ to int conversion in VC 2005

System::String^ to int conversion in VC 2005

System::String^ to int conversion in VC 2005

Hello. I'm still fairly new to C++, and I'm using the cookie-cutter style coding built into Visual Studio 2005 to help me out. From there, I'm adding additional code as needed.

What this means for me is, when I have a text box on a form, the default type of the Text field seems to be System::String^.

I'm trying to take a user input of integers in the text boxes to output to a binary file. Then, that file is made available to another program. I've got the file i/o all figured out, but when I try to take the value of the text box, I get an error that I can't convert from 'System::String ^' to 'int'.

This make sense to me as well, but I can't figure out how to get the data type of the text box to default to int (or maybe there is another method of doing what I am trying to do...). I have tried to cast with (int) and static_cast<int>, but these did not help.

I noticed that on other forms controls (for example, the progress bar control) there is a property called 'Value', but this is just not present for the text box control.

Here is what I am currently doing in short form...


int Value1;
Value1 = this->Value1TextBox->Text;
(write Value1 to file with int type)

Is there any way to make this conversion or is there another way to do this?

Thanks very much!

RE: System::String^ to int conversion in VC 2005

Ok... I've figured it out, though I found very little information about this method in books or google...

This is the correct conversion (or at least it's one way that works):


int Value1;
Value1 = System::Convert::ToInt32(this->Value1TextBox->Text);
(write Value1 to file with int type)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close