I'm working with special characters for mathematics in Excel.
(Exponents⁴, GRΣΣK, and other misc Unicode characters.)
I'd like to store commonly-used Unicode strings as global constants, since that would probably be significantly faster (and less bug-prone) than calling CStr()
each time I need one.
For example, I have these declarations outside all functions:
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
The problem is, whenever I try to reference one of these strings, the value is Empty
(If I turn on Option Explicit
I get an error for Variable not defined
)
What am I doing wrong?
Does VBA not support global constants as strings?