I keep getting the following errors in my program:
'System.Windows.Forms.TextBox.Text' is a 'property' but used like a 'method'
and
Non-invocable member 'System.Windows.Forms.Control.Text' cannot be used like a method.
Here is the code:
if (OffenceBox.Text != "")
{
AddBook(int.Parse(AgeBox.Text), NameBox.Text, AddressBox.Text, (HeightBox.Text), OffenceBox.Text());
}
else
{
MessageBox.Show("Age must be max 3 numbers in length");
}
}
How can I fix this problem?
EDIT:
Fixed the error and now encountered another:
Argument 4: Cannot convert String to int
and I can't seem to fix the problem.
Where you've written "OffenceBox.Text()", you need to replace this with "OffenceBox.Text". It's a property, not a method - the clue's in the error!
This worked but I have encountered another problem where
Argument 4: Cannot convert String to int
and I can't seem to fix it.int.Parse(HeightBox.Text) instead of (HeightBox.Text). The Text property is of type string so you need to try to convert it to an int, exactly like you did for AgeBox.Text. Box of these might not be convertible to int though so you need to catch the resulting Exception.