little help with these errors?

OK So here is my problem..
I am using Visual C++ 2010 Express and a Form project..

This part of my code is giving the problem

1
2
3
4
5
6
7
8
if (abut->Checked == true) 
				    
					Accel acc1;
					s = sbox->Text;
					u = ubox->Text;
					v = vbox->Text;
					t = tbox->Text;
					abox->Text = acc1.Acceleration(a, s, u, v, t);


Errors are in these lines
s = sbox->Text;
u = ubox->Text;
v = vbox->Text;
t = tbox->Text;

Following errors:
1
2
3
4
5
6
7
8
9
10
11
12
1>c:\users\aniq\documents\visual studio 2010\projects\projectoop\projectoop\Form1.h(318): error C2440: '=' : cannot convert from 'System::String ^' to 'int'
1>          No user-defined-conversion operator available, or
1>          There is no context in which this conversion is possible
1>c:\users\aniq\documents\visual studio 2010\projects\projectoop\projectoop\Form1.h(319): error C2440: '=' : cannot convert from 'System::String ^' to 'int'
1>          No user-defined-conversion operator available, or
1>          There is no context in which this conversion is possible
1>c:\users\aniq\documents\visual studio 2010\projects\projectoop\projectoop\Form1.h(320): error C2440: '=' : cannot convert from 'System::String ^' to 'int'
1>          No user-defined-conversion operator available, or
1>          There is no context in which this conversion is possible
1>c:\users\aniq\documents\visual studio 2010\projects\projectoop\projectoop\Form1.h(321): error C2440: '=' : cannot convert from 'System::String ^' to 'int'
1>          No user-defined-conversion operator available, or
1>          There is no context in which this conversion is possible


Something to do with string to int conversion or something else like that.

The thing here is I have to make the value of s,u,v,a,t equal to whatever is in the corresponding boxes.

Any help as to what I am doing wrong?
Last edited on
Hi,
if you convert the string to char* then you can use atoi (http://www.cplusplus.com/reference/clibrary/cstdlib/atoi/) to convert char arrays to int.
Or use QString instead which has a class method for this conversion.
greetings
Since this is C++/CLI, use Int32::Parse(), Int32::TryParse() or Convert.ToInt32() to convert from System::String^ to int.
[The problem is solved]

Thanks to both of you..

webJose I used Convert.ToInt32() but in visual C++ it goes like Convert::ToInt32() to convert from string to integer

Thanks again

Good Day
Last edited on
Topic archived. No new replies allowed.