我已經寫了這個函數來從字符串的開始和結尾刪除空白,任何想法爲什麼它不工作?從vba中的字符串的開頭和結尾刪除空格
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
Pearson'site的[cell view addin](http://www.cpearson.com/excel/CellView.htm)將有助於確定有問題的空白。如果它是CHAR(160)'non-breaking-space character,我不會感到驚訝。 – brettdj