Function_ application tips for ASP to remove string-and-tail continuous carriage returns and spaces

Source: Internet
Author: User

Copy Code code as follows:

' Get rid of consecutive carriage returns and spaces at the ends of a string
function Trimvbcrlf (str)
TRIMVBCRLF=RTRIMVBCRLF (Ltrimvbcrlf (str))
End Function

' Remove successive carriage returns and spaces at the beginning of the string
function Ltrimvbcrlf (str)
Dim Pos,isblankchar
Pos=1
Isblankchar=true
While Isblankchar
If mid (str,pos,1) = "" Then
Pos=pos+1
ElseIf Mid (str,pos,2) =vbcrlf Then
Pos=pos+2
Else
Isblankchar=false
End If
Wend
Ltrimvbcrlf=right (Str,len (str)-pos+1)
End Function

' Remove consecutive carriage returns and spaces at the end of the string
function Rtrimvbcrlf (str)
Dim Pos,isblankchar
Pos=len (str)
Isblankchar=true
While Isblankchar and pos>=2
If mid (str,pos,1) = "" Then
Pos=pos-1
ElseIf Mid (str,pos-1,2) =vbcrlf Then
Pos=pos-2
Else
Isblankchar=false
End If
Wend
Rtrimvbcrlf=rtrim (Left (Str,pos))
End Function

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.