[求助]请帮我写一个VB小程序,谢谢好心人啦
请帮我写一个函数实现字符过滤,过滤所有字符中间的空格,包括中间和前后的.谢谢哪位好心人啦.
试试这个,虽然麻烦,但绝对可靠:
Private Function GetString(Expression As String) As String
Dim strValue As String
Dim AscCode As Integer
Dim Msg As String
Dim i As Integer
Dim L As Integer
Dim strValue1 As String
Msg = Text1
L = Len(Expression)
For i = 1 To L
strValue = Mid$(Msg, i, 1)
AscCode = Asc(strValue)
If AscCode <> 32 Then
strValue1 = strValue1 & strValue
End If
Next
GetString = strValue1
End Function
你仔细看过你的代码没?
text1?那个是你传递的参数?你传递过去的text1之被获取len用了,msg直接定义=text1,所以我说没function的意义。不管换什么都是对text1进行处理,只是处理的长度再变。。还有居然说replace不行汗死~