簡體   English   中英

VBA宏Excel:如何從Excel單元格中讀取Unicode字符

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

我正在努力從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

如果用戶修改了復選框符號,我需要讀取Unicode字符才能看到。 我不知道如何將Unicode字符與單元格值進行比較..

有時你需要的只是第二雙眼睛。 :)

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