FormatString Function:
Formats a string upon a reference mask.
Description:
The Format function converts the numeric value to a text string and gives you control over the strings appearance. The Format function uses the # character as pattern mask.
Syntax:
strFormattedString = FormatString(StringToFormat, FormatPattern)
Example:
<%
response.write FormatString("Code1234567890", "[####] ####-####-SL##") '--- returns: [Code] 1234-5678-SL90
%>
ASP Source Code:
<%
Public Function FormatString(byVal StringToFormat, byVal FormatPattern) Dim i, sTemp, sResult sTemp = CStr(StringToFormat) sResult = FormatPattern Do Until InStr(sResult, "#") = 0 i = InStr(sResult, "#") sResult = Replace(sResult, "#", Left(sTemp, 1), 1, 1) sTemp = Mid(sTemp, 2) if Len(sTemp) = 0 Then sResult = Left(sResult, i) Loop FormatString = sResult End Function
%>
|