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,961 of 10,840    |
|    J French to All    |
|    Re: visual basic input validation intege    |
|    14 Mar 06 10:14:19    |
   
   XPost: comp.programming   
   From: erewhon@nowhere.uk   
      
   On Tue, 14 Mar 2006 11:20:21 +0200, Lord Duran    
   wrote:   
      
      
      
      
   >It seems to me that a simple cast and cast back can be used for validation:   
   >   
   >Function MyIsNumeric(ByVal cand as String) as Boolean   
   > If cand = CStr(CLng(cand)) Then   
   > MyIsNumeric = True   
   > Else   
   > MyIsNumeric = False   
   >End Function   
   >   
   >But take that with a grain of salt, I haven't actually tested it.   
      
   It will blow big time - if the String contains 'FRED'   
      
   Incidentally you are mis-using the word 'Cast'   
   - CStr and CLng are are Functions that 'Convert'   
   ( the 'C' stands for Convert - 'Cast' is something entirely different   
   better not gone into now )   
      
   With Error Handling then what you suggest is half way there   
      
   IMO the best method is to handle all checking extremely rigorously   
      
   --- 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