Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to delete a character from a string?
Message
 
À
17/11/2002 00:15:06
Henry Ravichander
RC Management Systems Inc.
Saskatchewan, Canada
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00723590
Message ID:
00723592
Vues:
15
Hi Henry,

I'm curious to know what language you are most trained in.
(It can't be VFP because you're working way too hard to accomplish something as simple as this!)

Here's a better way of trimming leading '0' characters and converting your string to numeric all at once:
mFeeApproved = VAL(mFeeApproved)
** To make sure you get the right number of decimals make sure to:
SET DECIMALS TO 2
BTW, your "DELETE SUBSTR(mFeeApproved,mSelectedPlace,mEndPlace)" code is failing because the keyword "DELETE" is used to mark table rows for deletion and not removing characters from a string.

If you were trying to remove a character from a string you might try something like this:
m.MyString='abcdefg'
m.MyString=STUFF(m.MyString,3,1,'')
? m.MyString
Good luck!

Hugh

>Hi all:
>
>I have the following code.
>
>
mSelectedPlace = 1 && first position in a substr
>		mEndPlace = 1 && position to set in a substr
>		DO WHILE mOK = .f.
>			mSelectedCharacter = "" && will hold a char
>			mSelectedCharacter = SUBSTR(mFeeApproved,mSelectedPlace,mEndPlace)
>				IF mSelectedCharacter = "0"
>					DELETE SUBSTR(mFeeApproved,mSelectedPlace,mEndPlace) && code fails here!
>                                        mSelectedPlace = mSelectedPlace + 1
>					mEndPlace = mEndPlace+1
>					LOOP			
>				ELSE
>					EXIT
>					
>				ENDIF
>		enddo
>
>The idea is to check the first char in the string, and if it is a zero, delete it from the variable mFeeApproved. Then loop to the check the next position till no more chars are left in that string to be evaluated.
>
>I would also like to know how to convert mFeeapproved from string to a number i.e. if the final value of mFeeApproved was "2100", I would like it to be converted to a numeric value and display as 21.00.
>
>Thank you for your suggestions.
Microsoft hears loudest what the VFP community says about Visual FoxPro by looking at the bottom line!

Support the product. Buy the latest version!

Hugh Winters @ WorldData 408-512-1131
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform