Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Character to numeric conversion
Message
De
29/12/2007 07:58:27
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Divers
Thread ID:
01278292
Message ID:
01278295
Vues:
18
In the example, first you have to get rid of "-" and "/", for instance:


? chrtran("123-456/789", "-/", "")


(If you want to get rid of any non-numeric character, it is slightly more complicated. Also, think whether you want to get rid of points (".") or not.)

The result can then easily be converted to numeric, with val().

>I have table with character field (size 15)
>
>for example: 0719996-0001/71
>
>Now I realized that this field must be numeric not character
>I have many users
>
>I will send all users the new software where the table contains
>the same field as numeric
>
>I need:
>
>If the field type is character, replace all them
>with only numbers
>
>so: 0719996-0001/71 will be 0719996000171
>
>This is an import wizard I will create
>
>Notice that in the future I will have uses whose software still contain
>caracter field type and other users not
>
>So I have to check the field type before conversion
>
>Moises
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform