Hi,
Could someone help me to convert the following code in to VBa? Appreciate your help. thanks.
EDIT: added code tags - Moderator
Could someone help me to convert the following code in to VBa? Appreciate your help. thanks.
Rich (BB code):
private static string ampersandReplacement = "&#" + ((int)'&') + ";";
private static string singleQuoteReplacement = "&#" + ((int)'\'') + ";";
private static string doubleQuoteReplacement = "&#" + ((int)'"') + ";";
private static string lessThanReplacement = "&#" + ((int)'<') + ";";
private static string greaterThanReplacement = "&#" + ((int)'>') + ";";
public static String substituteString(String originalStr)
{
// string substituteString(stringtring originalStr)
if (originalStr == null || "".Equals(originalStr))
return "";
StringBuilder replacedSB = new StringBuilder();
for (int i = 0; i < originalStr.Length; i++)
{
char currChar = originalStr;
switch (currChar)
{
case '&':
replacedSB.Append(ampersandReplacement);
break;
case '\'':
replacedSB.Append(singleQuoteReplacement);
break;
case '"':
replacedSB.Append(doubleQuoteReplacement);
break;
case '<':
replacedSB.Append(lessThanReplacement);
break;
case '>':
replacedSB.Append(greaterThanReplacement);
break;
default:
replacedSB.Append(currChar);
break;
}
}
return replacedSB.ToString();
}
EDIT: added code tags - Moderator