[转载]VBA学习笔记之Text(六)——删除字符串中多余的空格
(2013-06-04 20:12:35)
标签:
转载 |
原文地址:VBA学习笔记之Text(六)——删除字符串中多余的空格作者:空空空
- LTrim函数删除字符串前面的空格;
- RTrim函数删除字符串后面的空格;
- Trim函数删除字符串两头的空格(和excel中的函数Trim不同之处在于,其不能将字符串中间多余的空格删除)
Sub DemoTrims()
Dim str As String
str = " this is a string to trim. "
Debug.Print "LTrim:", ">"; LTrim(str); "<"
Debug.Print "RTrim:", ">"; RTrim(str); "<"
Debug.Print "Trim:", ">"; Trim(str); "<"
Debug.Print "Excel Trim:", ">"; _
WorksheetFunction.Trim(str); "<"
End Sub
LTrim:>this is a string to trim. <</DIV>RTrim: > this is a string to trim.<<BR>Trim: >this is a string to trim.<<BR>Excel Trim: >this is a string to trim.<<BR>
前一篇:《第56号教室的奇迹》读后感三
后一篇:北京游记