【问题标题】:Converting string to ASCII number将字符串转换为 ASCII 数字
【发布时间】:2016-03-02 00:55:14
【问题描述】:

我正在尝试使用 Excel VBA 编写一个函数来将字符串转换为其各自的 ASCII 数字。例如:

"ABCD" => "65666768"

我已经编写了这段代码,但它无法进行转换:

Public Function asciien(s As String) As String
' Returns the string to its respective ascii numbers
   Dim i As Integer

   For i = 1 To Len(s)
      asciien = asciien & CStr(Asc(Mid(s, x, 1)))
   Next i 

End Function

【问题讨论】:

    标签: vba excel


    【解决方案1】:

    这一行

    asciien = asciien & CStr(Asc(Mid(s, x, 1)))
    

    应该阅读

    asciien = asciien & CStr(Asc(Mid(s, i, 1)))
    

    “x”没有价值

    【讨论】:

    • 感谢您指出错误。它再次尝试了代码,但仍然给我“#NAME”值错误。
    • 检查您在工作表上的函数名称是否拼写正确,并且该函数的代码不在工作表对象中,它应该在自己的模块中
    • 谢谢!我忘了启用宏。现在问题解决了。非常感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-13
    • 1970-01-01
    • 2015-03-29
    • 2018-03-21
    • 1970-01-01
    相关资源
    最近更新 更多