Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Elaborating on my last post.(Text Boxes) 1

Status
Not open for further replies.

Bongo2k

Technical User
Apr 20, 2005
5
GB
Im using Visual C++ .NET 2003. I have my form set up for 2 input boxes for Start and End Time. Ive made the app fine with MFC, but MFC seems to have a outdated feel about it...anyway. Im trying to associate the variable with each text box so i can perform mathmatical calculations with it, but i get the convert error. Can Text Boxes not display integer variables or something?
 
i'm an mfc beginner.. but try casting to a char * or using itoa(). if you are tyring to get the integer as input, then yes, it will be a char *, use atoi to convert it to an int.

i'm also not clear on one thing.. are you having a hard time associating a variable with a text box? because i know vc 6 lets you do this quite easily using the class wizard (ctrl-W)..
 
Like i said, ive done it fine with MFC, setting the variable as a control variable for the text box then just assigning numbers to the variable later in the program. As far as i can see using .net forms i cant associate a variable with a text box. I can use text as a variable and it works fine, TextBox1->Text = myvariable, with int my variable and then TextBox1->Text = my variable i get Form1.h(863): error C2664: 'void System::Windows::Forms::TextBox::set_Text(System::String __gc *)' : cannot convert parameter 1 from 'int' to 'System::String __gc *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast. Ah, i didnt see the last line of the error, i guess thats casting from int to char with itoa right?
 
Like i said, ive done it fine with MFC, setting the variable as a control variable for the text box then just assigning numbers to the variable later in the program. As far as i can see using .net forms i cant associate a variable with a text box. I can use text as a variable and it works fine, TextBox1->Text = myvariable, with int my variable and then TextBox1->Text = myvariable i get Form1.h(863): error C2664: 'void System::Windows::Forms::TextBox::set_Text(System::String __gc *)' : cannot convert parameter 1 from 'int' to 'System::String __gc *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast. Ah, i didnt see the last line of the error, i guess thats casting from int to char with itoa right?
 
Doh, sorry about the double post, i guess you cant edit posts :/
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top