我编写了这个函数来删除字符串开头和结尾的空格,你知道为什么它不起作用吗?
Public Function PrepareString(TextLine As String)
Do While Left(TextLine, 1) = " " ' Delete any excess spaces
TextLine = Right(TextLine, Len(TextLine) - 1)
Loop
Do While Right(TextLine, 1) = " " ' Delete any excess spaces
TextLine = Left(TextLine, Len(TextLine) - 1)
Loop
PrepareString = TextLine
End Function
我测试了你的功能,在我的机器上运行良好。
您可以使用内置的Trim()
函数为您执行此操作,而不是创建执行相同操作的 UDF。
Trim(TextLine)
参考:http://www.techonthenet.com/excel/formulas/trim.php http://www.techonthenet.com/excel/formulas/trim.php
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)