calling function from UI

Hi… I am new to Xojo. I am learning the basics using the tutorials.
I was trying to create a function. i need to call the function from UI
i am getting the error saying “expected double, but got string.”

The following is the code in method.
Dim theArea As Double
theArea = length *length
Return theArea

the following is the code in pushbutton Action

Label1.Text = Area(double(TextField1.text))

Right, so let’s say you have a textField.

If your method is defined as:

Function Area(length as Double) as Double

You’ll need to call it like this:

dim theArea as Double = Area(val(textField1.text))

Text and numbers are something different to a computer, they are different data types even if to us they look identical. To distinguish them quotes are placed around text.

Mathematical operations are also different for text and for numbers.

For example If you add up text like “Markus” + " is " + “weird” then you end up with “Markus is weird”

And if you add up text like “5” + “8” + “2” then you end up with “582”

If however you add up numbers like 5 + 8 + 2 then you end up with 15

When you enter TEXT in a TEXTfield and you want to do maths on this input, then you have to convert the text to it’s numerical equivalent - that’s what the VALUE function Val does.

Thanks for your reply… It helped me a lot.