Replace(expression, find, replace[, start[, count[, compare]]])
举例:替换掉字符串颤神中空物笑格罩洞含
Dim a As String
a = "◆ ab c ◆"
MsgBox Replace(a, " ", "")
要那么麻烦干嘛,占用篇幅,正搜还费头脑去看和理念森清芹。
用最简此毕单的就好了
Replace(字符串, " ", "")
例:
text1.text=Replace(text1.text, " ", "")
类似 dim a as stringa=" a b"然后你可以调用a.trim()就是哪绝亏去宏卜掉李神空格。
'这样,可去除空游知樱格
Private Sub Command1_Click()
dim a as string,b as string
a="神丛1234 5678"
for i=1 to len(a)
if mid(a,i,1)<>" "猛渗 then
b=b & mid(a,i,1)
end if
next i
print "去除空格前: " & a
print "去除空格后: " & b
end sub
'此函漏伍数KillSpace用以返察或除去字没芹符串中的空格,请将此函数粘贴到代码窗口空白处。(不在任何Sub过程里)Function KillSpace(Expression)
Dim tmpS
For i = 1 To Len(Expression)
tmpT = Mid(Expression, i, 1)
If tmpT <> " " Then tmpS = tmpS & tmpT
Next i
KillSpace = tmpS
End Function'在某个过程里调用此函数,例如:Private Sub Command1_Click()Text1.Text=KillSpace("7 591 6512 1458 050")End Sub'这样在Text1里就显示:759165121458050
类似
dim a
as
string
a="
a
b"
然后你可差缺以调用a.trim()就是镇庆宏去掉空御册格。
令a=你需大孙要去除空格脊帆的樱仿雹字符串
dim
b(len(a))
for
i=1
to
len(a)
b(i)=mid(a,i,1)
if
b(i)<>"
"
then
a=a◆b(i)
end
a就是去除空格后的字符串
以上就是土嘎嘎小编大虾米为大家整理的vb去掉字符串中的空格_vb中去除字符串头尾空格的函数是什么?相关主题介绍,如果您觉得小编更新的文章对您有所帮助,不要忘记讲本站分享给您身边的朋友哦!!