Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Stuff() VFP equivalent in .NET
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 8.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01354694
Message ID:
01354697
Vues:
19
This message has been marked as the solution to the initial question of the thread.
>Just out of curiosity, but has anyone wrote a Stuff() VFP equivalent in .NET? I have all kinds of functions in there but I never converted that one yet.


Here is what the creators of the VFP Toolkit for .NET did (http://foxcentral.net/microsoft/VFPToolkitNET.htm)
		public static string Stuff(string cExpression, int nStartReplacement, int nCharactersReplaced, string cReplacement)
		{
			//Create a stringbuilder to work with the string
			StringBuilder sb = new StringBuilder(cExpression);

			if(nCharactersReplaced + nStartReplacement -1 >= cExpression.Length)
				nCharactersReplaced = cExpression.Length - nStartReplacement + 1;


			//First remove the characters specified in nCharacterReplaced
				if (nCharactersReplaced != 0)
				{
					sb.Remove(nStartReplacement - 1, nCharactersReplaced);
				}

			//Now Add the new string at the right location
			//sb.Insert(0,cExpression,nTimes);
			sb.Insert(nStartReplacement - 1,cReplacement);
			return sb.ToString();
		}
The link has the VB source code
Semper ubi sub ubi.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform