'========================================
' NUMERIC INPUT - NUMBERS ONLY
' by cundo Liberty Basic Conforums
' Re: textbox input - numbers only
' Reply #10 on 23 April 2016 at 6:15pm
'========================================
' Modification to Symbols$ removes "-"
' from the exclusion list. This allows
' negative numbers to be included.
'----------------------------------------
' The function num$(d$)has been included
' for LBB which does not recognise
' remchar$. The function num$(d$) is a
' modification of the routine provide in
' Liberty Basic Conforums by GaRPMorE in
' Reply #6 on: Apr 22nd, 2016, 7:23pm
'========================================
nomainwin
textbox #main.textbox, 10, 50, 100, 25
WindowWidth = 350
WindowHeight = 150
open "Filtered Numeric Input" for window as #main
#main.textbox "!contents? txt$"
#main "trapclose [quit]"
[CheckInput]
timer 0
#main.textbox "!contents? txt$"
Symbols$ = "abcdefghijklmnopqrstuvwxyz";_
"ABCDEFGHIJKLMNOPQRSTUVWXYZ<>,:;!@#$%^&*()_=+`~"
oldtxt$=txt$
'txt$ = remchar$( txt$ , Symbols$)
txt$ = num$(txt$) 'replacement for remchar$()
if oldtxt$<> txt$ then
#main.textbox txt$
handle = hWnd(#main.textbox)
pos = len(txt$)
calldll #user32, "SendMessageA", _
handle as ulong, _
_EM_SETSEL as long, _
pos as long, _
pos as long, _
result as void
end if
timer 300, [CheckInput]
wait
function num$(d$)
for i=1 to len(d$)
a=asc(mid$(d$,i,1))
if a = 45 or a = 46 or a>47 and a<58 then num$=num$+chr$(a)
next
end function
[quit]
close #main
end