No, it will notThere are a couple of ways to implement them, some of which are more efficient than others.
The str$(val()) method is the fastest method, but it's not the most robust. For one thing, it works only for integers. However, it's great for quick applications that require only integers. For robust, idiot-proof applications, you need more sophisticated validation routines. It is possible, of course, to write a routine that scans the string for the correct format, but this can be very slow, given that you have to make calls to mid$() for every character in the string. If you've been programming for any length of time, you've probably written one that you can adapt to MapBasic. Or you can write one in a faster language, put it in a DLL, and link to it from MapBasic (scanf is NOT recommended). Another method is to try assigning the string to a MapBasic window variable, and catching any errors. This method is optimal for validating strings that can take non-integer values. run command "Dim v_dbl as float" ... function good_float (ByVal s as string, f as float) as logical On Error Goto notvalid run command "v_dbl="+sval OnError goto 0 f=val(Sval) good_float = true exit function notvalid: resume failure failure: good_float = false end function Hope this helps Spencer -----Original Message----- From: B. Thoen [mailto:[EMAIL PROTECTED] Sent: Monday, May 17, 2004 11:05 AM To: Tim.Nuteson Cc: [EMAIL PROTECTED] Subject: Re: SUM: MI-L Testing to ensure a string is numeric Would that algorithm return the correct result if you fed it a numeric string like '0023456', or are numbers with leading zeros not going to be encountered? On Mon, 17 May 2004, Tim.Nuteson wrote: > Thanks to all who responded to my question: How can I ensure that a > value entered into an EditText control of a MB dialog is numeric? The > simplest solution was offered by Michael Taylor, Martin Highham, and > Robert Crossley: > > If str$(val(teststring)) = teststring then > 'numeric > Else > 'not > End If > > Thanks again, > > Tim Nuteson > Target > > > --------------------------------------------------------------------- > List hosting provided by Directions Magazine | www.directionsmag.com | > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > Message number: 11784 > --------------------------------------------------------------------- List hosting provided by Directions Magazine | www.directionsmag.com | To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Message number: 11788 --------------------------------------------------------------------- List hosting provided by Directions Magazine | www.directionsmag.com | To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Message number: 11789
