wowpedia
Main Menu


This function reads text entered into the editBox, tries to convert it into a number, and returns corresponding numerical value, or 0 if text didn't look like a number.

num = editBox:GetNumber()

Arguments

none

Returns

num
number entered in the EditBox

Details

This function proves to be very useful when reading in numbers. While GetText() will return a string, which you can't perform any arithmetic operations or comparison with, this function converts the TextString to a number. This will even work for all strings that are considered as well formed numerical constants in lua (so it will work for '314.16e-2' too).

Function will scan editbox text and return once it finds text which cannot be interpreted as part of a number. It will return number recognized so far, or 0 if there were no valid digits recognized. The function will never return nil. For example (User input => Function returns):

Note

To verify that a 0 returned is indeed the numerical value in the editbox field, convert the results of GetNumber() to a string using tostring(), and compare to the results of GetText().