gpt4 book ai didi

excel - VBA:全局常量字符串

转载 作者:行者123 更新时间:2023-12-05 01:17:15 27 4
gpt4 key购买 nike

<分区>

我正在 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 不支持全局常量作为字符串吗?

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com