简体   繁体   English

VBA宏Excel:如何从Excel单元格中读取Unicode字符

[英]VBA Macro Excel: How to read a Unicode character from Excel cell

I am struggling to read a Unicode character back from a cell in VBA Excel. 我正在努力从VBA Excel中的单元格中读取Unicode字符。

Sub mySub()
    Cells(1, "A").Value = ChrW(10003)   ' Writes checkbox symbol to A1

    MsgBox Asc(Cells(1, "A").Value)     ' Output:  63 (questionmark symbol)
                                        ' Expected Output: 10003
End Sub

I need to read the Unicode character to see, if the checkbox symbol was modified by a user. 如果用户修改了复选框符号,我需要读取Unicode字符才能看到。 I have no Idea how to compare a Unicode character with the cells value.. 我不知道如何将Unicode字符与单元格值进行比较..

Sometimes all you need is second pair of eyes. 有时你需要的只是第二双眼睛。 :) :)

Sub mySub()
    Cells(1, "A").Value = ChrW(10004)   ' Writes checkbox symbol to A1

    'MsgBox Asc(Cells(1, "A").Value)     ' Output:  63 (questionmark symbol)
                                   ' Expected Output: 10003
    '/ Works! 
    MsgBox AscW(Cells(1, "A").Value2)    'Almost there. Use AscW instead of Asc
End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM