3
Answers

Compiler errors re: label and textbox

ray dona

ray dona

16y
4.5k
1

Hi,

I have placed a button, label and a text box on a form. In the button's event handler I have written the following code:

int cost;

int money;

Label->Show("Insert " + cost + " pence");

money = textBox->Text;

When I try to output text to the label I get the following compiler error:

error C2660: 'System::Windows::Forms::Control::Show' : function does not take 1 arguments

Also when I try to assign an int variable entered in text box I get following error:

error C2440: '=' : cannot convert from 'System::String ^' to 'int'error

Even if I try to cast from String to int I get error:

money = (int)textBox->Text;

C2440: 'type cast' : cannot convert from 'System::String ^' to 'int'

I would be grateful if someone could show me how to get round these errors.

Answers (3)