调试VBA中的空白 [英] Debugging whitespace in VBA
问题描述
我的表格中有一个单元格:
I have a cell in a table that reads:
64123
哪里有一些空格之后3.我以为这是一个空白的空间,所以在我的vba代码中,我尝试了多种方法来获得字符串的空格,但是没有 application.trim
或替换
工作。
64123
where there is some sort of white space after 3. I thought it was a blank space, so in my vba code, I've tried multiple ways of getting this blank space OUT of the string, but neither application.trim
nor replace
work.
With Cells(c.Row, 16)
.NumberFormat = "General"
v = Application.Trim(.Text)
v = Replace(v, " ", "")
Debug.Print v
.Clear
.NumberFormat = "General"
.Value = Application.Trim(v)
End With
结束时绝对有一个空白 - 当我突出显示Excel中的单元格时,我可以看到它,而 Application.Trim
总是为我工作这还有什么可以不是一个空白的空间?如果它是一个选项卡或一个回车符,那些替换
语法是什么?
There is definitely a blank space at the end - I can see it when I highlight the cell in Excel, and Application.Trim
has ALWAYS worked for me. What else could this be other than a blank space? If it's a tab or a carriage return, what's the replace
syntax for those?
推荐答案
运行它,它会告诉你所有字符串的ascii值
run this and it will tell you all the ascii values of your string
Sub tellMeWhatCharValues(h As String)
Dim i
For i = 1 To Len(h)
MsgBox Asc(Mid(h, i, 1))
Next i
End Sub
只是第七个字符
Sub tellMeWhatCharValues(h As String)
Dim i
MsgBox Asc(Mid(h, 7, 1))
End Sub
这篇关于调试VBA中的空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!