home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.visual.basic      MS Visual Basic discussions, NOT dot-net      10,840 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 9,939 of 10,840   
   Steve Gerrard to tac@tac.co.uk   
   Re: visual basic input validation intege   
   03 Mar 06 18:03:51   
   
   XPost: comp.programming   
   From: mynamehere@comcast.net   
      
   "code_wrong"  wrote in message   
   news:44074b40$1_2@mk-nntp-2.news.uk.tiscali.com...   
   >   
   > interesting,  you have made a comprehensive study of the flawed isNumeric()   
   > function   
      
   Since Rick posted his IsNumeric post, I will toss in mine as well :)   
      
   IsNumeric has one particular purpose, which it does well, so it is not flawed.   
   Its function is to determine whether or not a particular expression can be   
   converted to a number without causing an error.   
      
   As Rick points out, the test   
      
       IsNumeric("($1,23,,3.4,,,5,,E67$)")   
      
   returns True, which is correct, because the conversion   
      
       X = CDbl("($1,23,,3.4,,,5,,E67$)")   
      
   will assign X the value   
      
       -1.23345E+70   
      
   rather than raising an error.   
      
   In case you are curious, the conversion will ignore the commas and $, since   
   they   
   are allowed in numeric expressions, and it will treat the enclosing parentheses   
   as an accountant's version of a minus sign.   
   That gives it -1233.45 E67, which the VB immediate window then displays in   
   "proper" scientific notation.   
      
   IsNumeric is not meant to be, and quite plainly is not, a strict input parsing   
   function, but is rather a programming tool with which to avoid "Type Mismatch"   
   errors during conversions steps.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca