Information générale
Catégorie:
Codage, syntaxe et commandes
This is where VFP wins hands down. In these cases, you will need to loop through the character string byte by byte - and rebuild the string - based on what you need to replace each character with.
Here is a VB function that will work for you since you are doing a simple - 1 character replacement:
Function strtran(csearched As String, csearchfor As String, creplacement As String) As String
Dim x As Integer
x = 0
For x = 1 To Len(csearched)
If Mid(csearched, x, 1) = csearchfor Then
strtran = strtran + creplacement
Else
strtran = strtran + Mid(csearched, x, 1)
End If
Next x
End Function
>>VFP on the whole, has a much richer language - particulary in the string
>>manipulation and data manipulation arena.
>
>Speaking of which, I was trying to write an Append Query in Access the other day and assign cField to cDescription, and STRTRAN(cField, ' ', '_') to cPrimaryKey. Of course, Access doesn't support STRTRAN, so I ended up leaving the spaces in, which is not a wholly satisfactory solution. Any ideas?
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement