调试VBA中的空格

Bri*_*ell 5 excel vba excel-vba

我在表格中有一个单元格,内容如下:

64123在3之后有一些空白区域.我认为它是一个空白区域,所以在我的vba代码中,我尝试了多种方法将这个空白空间从字符串中取出,但既不能application.trim也不能replace工作.

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
Run Code Online (Sandbox Code Playgroud)

最后肯定有一个空白区域 - 当我在Excel中突出显示单元格时,我可以看到它,并且Application.Trim始终为我工作.除了空白之外,还有什么可以做的呢?如果它是制表符或回车符,那么它们的replace语法是什么?

Sor*_*eri 4

运行这个,它会告诉你字符串的所有 ascii 值

Sub tellMeWhatCharValues(h As String)
Dim i
    For i = 1 To Len(h)
        MsgBox Asc(Mid(h, i, 1))
    Next i
End Sub
Run Code Online (Sandbox Code Playgroud)

仅适用于第 7 个字符

Sub tellMeWhatCharValues(h As String)
Dim i
    MsgBox Asc(Mid(h, 7, 1))
End Sub
Run Code Online (Sandbox Code Playgroud)