WoW:API EditBox GetNumber
number = editBox:GetNumber()
If a number was entered, it returns a numerical value of the number. If anything else was entered (including nil) it returns 0.
- Arguments
none
- Returns
- number
- number
- Number - corresponding to the 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).
If you enter a string, or a hybrid like 'abc123def', the function returns 0.
If you enter a hybrid like 12abc34 the function will ignore everything after the last valid digit (thus returning 12 in the example)