vb输入字符串s,将s中的前导空格和尾随空格删去,中间连续多个空格缩减为一个空
1个回答
展开全部
去掉前后空格用Trim(),中间的空格麻烦点,要逐个字符分析
Dim c As String * 1
Dim strResult As String
Dim b As Boolean, i As Long
For i = 1 To Len(s)
c = Mid(s, i, 1)
If c = " " Then
If Not b Then
strResult = strResult & c
b = True
End If
Else
strResult = strResult & c
b = False
End If
Next i
Text2.Text = Trim(strResult)
Dim c As String * 1
Dim strResult As String
Dim b As Boolean, i As Long
For i = 1 To Len(s)
c = Mid(s, i, 1)
If c = " " Then
If Not b Then
strResult = strResult & c
b = True
End If
Else
strResult = strResult & c
b = False
End If
Next i
Text2.Text = Trim(strResult)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询