我正在使用 Excel 中的数学特殊字符。
(指数⁴、GRΣΣK 和其他其他 Unicode 字符。)
我想将常用的 Unicode 字符串存储为全局常量,因为这可能比CStr()
每次我需要一个时调用要快得多(并且不易出错)。
例如,我在所有函数之外都有这些声明:
Public Const STRPOWER0 As String = CStr(ChrW(&H2070)) '0th power
Public Const STRPOWER1 As String = "¹" 'CStr(ChrW(&HB9)) 1st power
Public Const STRPOWER2 As String = "²" 'CStr(ChrW(&HB2)) 2nd power
Public Const STRPOWER3 As String = "³" 'CStr(ChrW(&HB3)) 3rd power
Public Const STRPOWER4 As String = CStr(ChrW(&H2074)) '4th power
Public Const STRPOWER5 As String = CStr(ChrW(&H2075)) '5th power
Public Const STRPOWER6 As String = CStr(ChrW(&H2076)) '6th power
Public Const STRPOWER7 As String = CStr(ChrW(&H2077)) '7th power
Public Const STRPOWER8 As String = CStr(ChrW(&H2078)) '8th power
Public Const STRPOWER9 As String = CStr(ChrW(&H2079)) '9th power
Public Const STRPOWERNEGATIVE As String = CStr(ChrW(&H207B)) 'Superscript negative sign
问题是,每当我尝试引用这些字符串之一时,值是Empty
(如果我打开Option Explicit
我会收到错误Variable not defined
)
我究竟做错了什么?
VBA 不支持将全局常量作为字符串吗?