Testing for numeric input

Thomson, Martyn EDUC:EX Martyn.Thomson@gems1.gov.bc.ca
Tue, 18 May 2004 13:24:05 -0700


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C43D16.102787DC
Content-Type: text/plain;
	charset="iso-8859-1"

Hello listers,
Does anyone know of a simple way to test if the input to a text field is
numeric within a range -999.99 to +999.99 with the "+" being optional.
Using NCONVERT(fieldtext) causes a data expression error when the argument
is not numeric.
I looked at matching against every possible pattern the user could enter,
but since the "-","+" and "." are optional on input, and the range has be
taken into account, the number of combinations soon gets unmanageable.  
I could loop through each character matching against characters 0 to 9 , . -
+  but then coding to ensure that the plus, negative and period characters
are in appropriate positions and not repeated, also soon becomes lengthy.
There must be a more elegant method eh?

Regards, 
Martyn Thomson 
Ministry of Education, Victoria, BC 
  

 

------_=_NextPart_001_01C43D16.102787DC
Content-Type: text/html;
	charset="iso-8859-1"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">


<META content="MSHTML 6.00.2800.1400" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=593515719-18052004><FONT face=Arial size=2>Hello 
listers,</FONT></SPAN></DIV>
<DIV><SPAN class=593515719-18052004><FONT face=Arial size=2>Does anyone know 
of&nbsp;a simple way to test if the input to a text field is numeric within a 
range -999.99 to +999.99&nbsp;with the "+" being optional.</FONT></SPAN></DIV>
<DIV><SPAN class=593515719-18052004><FONT face=Arial size=2>Using 
NCONVERT(fieldtext) causes a data expression error when the argument is not 
numeric.</FONT></SPAN></DIV>
<DIV><SPAN class=593515719-18052004><FONT face=Arial size=2>I looked at matching 
against every possible pattern the user could enter, but since the "-","+" and 
"." are optional on input, and the range has be taken into account, the number 
of combinations soon gets unmanageable.&nbsp;&nbsp;</FONT></SPAN></DIV>
<DIV><SPAN class=593515719-18052004><FONT face=Arial size=2>I could loop through 
each character matching against characters 0 to 9 , . - +&nbsp;&nbsp;but then 
coding to ensure that the plus, negative and period characters are in 
appropriate positions and not repeated, also soon becomes 
lengthy.</FONT></SPAN></DIV>
<DIV><SPAN class=593515719-18052004><FONT face=Arial size=2>There must be a more 
elegant method eh?</FONT></SPAN></DIV>
<P><FONT face=Arial size=2>Regards,</FONT> <BR><FONT face=Arial size=2>Martyn 
Thomson</FONT> <BR><FONT face=Arial size=2>Ministry of Education,<SPAN 
class=593515719-18052004> </SPAN>Victoria, BC</FONT> <BR><FONT face=Arial 
size=2>&nbsp;</FONT> </P>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV></BODY></HTML>

------_=_NextPart_001_01C43D16.102787DC--