AddChr Function:
Adds characters to a string in a specific location.
Description:
The AddChr function is used to add characters to a string. There are three required arguments: Input, Addition, Location. The Input argument is the string to manipulate. The addition argument is a string of text to add to the Input string. The location argument is a long value representing the place to add the text specified in Addition to the Input string.
Syntax:
string = AddChr(Input, Addition, Location)
Example:
<%
dim a a = "Help Me! Trapped in computer"
'--- append ", can't get out" to the end of string a Response.Write AddChr(a, ", can't get out", Len(a)) & "<BR>" '--- returns: "Help Me! Trapped in computer, can't get out"
'--- write ", can't get out" to the tenth position from the '--- right of string a and append everything after that position to the end Response.Write AddChr(a, ", can't get out", Len(a) - 10) & "<BR>" '--- returns: "Help Me! Trapped i, can't get outn computer"
'--- write ", can't get out" before string a and append everything '--- after that position to the end Response.Write AddChr(a, ", can't get out", 0) & "<BR>" '--- returns: ", can't get outHelp Me! Trapped in computer"
%>
ASP Source Code:
<%
Private Function AddChr(byVal string, byVal addition, byVal location) Dim leftString, rightString On Error Resume Next leftString = Left(string, location) If Err Then leftString = "" location = 0 End If rightString = Mid(string, location + 1) AddChr = leftString & addition & rightString On Error GoTo 0 End Function
%>
|