'去除字符串中的空格(方法一)
Public Function DelBlank(SearchString As String)
DelBlank = Replace(SearchString, Chr(32), "")
End Function
'去除字符串中的空格(方法二)
Public Function DelBlank(SearchString As String)
Dim Strtemp As String
Dim LenTemp As Integer
Dim Blank() As String
LenTemp = Len(SearchString)
Strtemp = SearchString
ReDim Blank(LenTemp - 1)
For i = 1 To LenTemp
Strtemp = Left(Strtemp, 1)
If Not Strtemp = " " Then
Blank(i - 1) = Strtemp
End If
Strtemp = Right(SearchString, LenTemp - i)
Next
For i = 0 To LenTemp - 1
DelBlank = DelBlank + Blank(i)
Next
DelBlank = Trim(DelBlank)
End Function
1.用自定义函数
Public Function mytrim(ByVal vstr As String) As String
Dim a As Integer
Dim lstr As String
a = Len(vstr)
For i = 1 To a
k = Mid(vstr, i, 1)
If k <> " " Then lstr = lstr & k
Next
mytrim = lstr
End Function
2,用VB自带函数
replace(lstr," ","")
文章评论(0条评论)
登录后参与讨论