From: Salad on
David Kaye wrote:
> "Jon Lewis" <jon.lewis(a)cutthespambtinternet.com> wrote:
>
>>I rarely use the Like operator and below is the only way I could get a
>>function to return true if
>>str is all numbers or all numbers followed by a single letter
>>
>>Is there an easier way?
>
>
> I'm assuming you mean that 12345A is true and 12345 is true but A12345 if
> false and A is false.

That's what I assumed as well. If that's the case then
? Isnumeric(x) or (IsNumeric(Left(x,len(x)-1)) And not Isnumeric(x))
works OK.

>
> If that's the case I'd probably do:
>
> select case val(str$)
> case 10000 to 99999
> maybeok=true
> case else
> maybeok=false
> end select
> select case right$(str$,1)
> case "A" to "Z", "a" to "z"
> if maybeok then
> isokay=true
> else
> isokay=false
> end if
> case else
> isokay=false
> end select
>
From: David Kaye on
sfdavidkaye2(a)yahoo.com (David Kaye) wrote:

Slight correction. Note the 0 to 9 addition:

>select case right$(str$,1)
> case "A" to "Z", "a" to "z", "0" to "9"
> if maybeok then
> isokay=true
> else
> isokay=false
> end if
> case else
> isokay=false
>end select
>


From: Marshall Barton on
Salad wrote:

>> I'm assuming you mean that 12345A is true and 12345 is true but A12345 if
>> false and A is false.
>
>That's what I assumed as well. If that's the case then
> ? Isnumeric(x) or (IsNumeric(Left(x,len(x)-1)) And not Isnumeric(x))
>works OK.
>

Sometimes, but not always. IsNumeric will return True for
anything that can represent a number, even somewhat obscure
number styles such as:
+1.234E-3
-1.234D+3
$12.34-
$(12.34)
which makes IsNumeric useless in most situations where you
might expect it to work.

If you want to check for just 0-9 characters, the:
Not x Like "*[!0-9]*"
expression is the best I have been able to come up with.

--
Marsh
From: David Kaye on
salad(a)oilandvinegar.com wrote:

>That's what I assumed as well. If that's the case then
> ? Isnumeric(x) or (IsNumeric(Left(x,len(x)-1)) And not Isnumeric(x))
>works OK.

DUH! I'm surprised I didn't even think of that.

From: David Kaye on
Marshall Barton <marshbarton(a)wowway.com> wrote:

>Sometimes, but not always. IsNumeric will return True for
>anything that can represent a number, even somewhat obscure
>number styles such as:
>+1.234E-3
>-1.234D+3
>$12.34-
>$(12.34)
>which makes IsNumeric useless in most situations where you
>might expect it to work.

I think this is an unnecessary worry. No account number is going to have
those characters.

First  |  Prev  |  Next  |  Last
Pages: 1 2 3
Prev: formatting
Next: A2010 question regarding web app