Message
General information
Fórum:
Visual FoxPro
Category:
Programação, sintaxe e comandos
Miscellaneous
ID da thread:
00359011
ID da mensagem:
00359121
Views:
14
lcCheckNumber = STR(VAL(CHRTRAN(lcCheckNumber, CHRTRAN(lcCheckNumber, "0123456789", ""), "")))

The inner chrtran returns a string with all chars (in lcCheckNumber) that are not digits. The outer chrtran
removes all these chars. Str and val remove any leading zeros.

Vlad

>Hi All,
>
>I need a quick and elegant (quick's better) to clean up a char field that must contain only numbers.
>
>I have to process some tables that are downloaded from several check cashing stores. Check cashing employees are among the most creative types I've ever come accross.
>
>The app they're using on their end allows them to enter anything in the check number field, so sometimes we end up with "0000243" or "0234r;23".
>
>What I need to do is go through the table and spot anything that has leading zeros or characters as part of the string, so that the two samples above would become "243" and "23423", respectively.
>
>I've created a few different algorithms, but would like to get some ideas from others.
>
>So far the fastest I've found is to go through the whole table and check every record with:
>
>if str( val( checknum)) <> checknum
> *something's not kosher with this number
>endif
>
>If anyone has a more creative approach, please let me know...
>
>Thanks!
>
>Alex
Previous
Responder
Mapa
View