Testing for numeric input

Guy Werry guy.werry@hbms.ca
Tue, 18 May 2004 15:35:10 -0500


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_01C43D17.9D8A3880
Content-Type: text/plain;
	charset="iso-8859-1"

Martyn,
 
At the risk of sounding like an idiot, why wouldn't you just declare the
field as numeric?  That way Powerhouse takes care of everything for you,
particularly if you make use of the VALUES clause in the dictionary.
 
Guy Werry.

-----Original Message-----
From: Thomson, Martyn EDUC:EX [mailto:Martyn.Thomson@gems1.gov.bc.ca]
Sent: May 18, 2004 3:24 PM
To: POWERHOUSE NEW (E-mail)
Subject: Testing for numeric input


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_01C43D17.9D8A3880
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 5.50.4522.1800" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=830452720-18052004>Martyn,</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=830452720-18052004></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=830452720-18052004>At the 
risk of sounding like an idiot, why wouldn't you just declare the field as 
numeric?&nbsp; That way Powerhouse takes care of everything for you, 
particularly if you make use of the VALUES clause in the 
dictionary.</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=830452720-18052004></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=830452720-18052004>Guy 
Werry.</SPAN></FONT></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
  <DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma 
  size=2>-----Original Message-----<BR><B>From:</B> Thomson, Martyn EDUC:EX 
  [mailto:Martyn.Thomson@gems1.gov.bc.ca]<BR><B>Sent:</B> May 18, 2004 3:24 
  PM<BR><B>To:</B> POWERHOUSE NEW (E-mail)<BR><B>Subject:</B> Testing for 
  numeric input<BR><BR></FONT></DIV>
  <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></BLOCKQUOTE></BODY></HTML>

------_=_NextPart_001_01C43D17.9D8A3880--