Function Strlength (STR)
Temp_str=len (STR)
For I=1 to Temp_str
Test_str= (Mid (str,i,1))
If ASC (test_str) >0 Then
Strlength=strlength+1
Else
Strlength=strlength+2
End If
Next
End Function
Function Strleft (str,l)
Temp_str=len (STR)
For I=1 to Temp_str
Test_str= (Mid (str,i,1))
Strleft=strleft&test_str
If ASC (test_str) >0 Then
Lens=lens+1
Else
Lens=lens+2
End If
If lens>=l Then Exit for
Next
End Function
Function Strright (str,l)
Temp_str=len (STR)
For i = Temp_str to 1 step-1
Test_str= (Mid (str,i,1))
Strright=test_str&strright
If ASC (test_str) >0 Then
Lens=lens+1
Else
Lens=lens+2
End If
If lens>=l Then Exit for
Next
End Function
For example, a Chinese character will only be counted as a byte, in typesetting, if all is Chinese characters, say, anyway, no difference, but if the string has been manipulated by Chinese characters and English letters, it is inconvenient, the following three functions can replace the ASP's own related functions.
The
also has a place for attention, if used in a loop, because the invariant "I" is also a variable that is often used for loops, the value of "I" will change when the following function is executed, and if the same variable is used in the call to his loop, an unknown result is generated, please replace it with another variable name.