Dim str As String = " ByCAD By CAD " MsgBox("|" & str.TrimStart() & "|") '去除开头空格 MsgBox("|" & str.TrimEnd() & "|") '去除结尾空格 MsgBox("|" & str.Trim() & "|") '去除首尾空格