作者:mobiledu2502868933 | 来源:互联网 | 2023-06-10 08:19
Is it possible to either:
有没有可能:
Declare an array as a constant
将数组声明为常量
OR
或
Use a workaround to declare an array that is protected from adding, deleting or changing elements, and therefore functionally constant during the life of a macro?
使用一个变通方法来声明一个数组,该数组可以避免添加、删除或更改元素,因此在宏的生命周期中,功能常量?
Of course I could do this:
我当然可以做到:
Const myConstant1 As Integer = 2
Const myConstant2 As Integer = 13
Const myConstant3 As Integer = 17
Const myConstant4 ...and so on
...but it loses the elegance of working with arrays. I could also load the constants into an array, and reload them each time I use them, but any failure to reload the array with those constant values before use could expose the code to a "constant" value that has changed.
…但是它失去了使用数组的优雅性。我还可以将这些常量加载到一个数组中,并在每次使用它们时重新加载它们,但是在使用之前使用这些常量重新加载数组的任何失败都可能使代码暴露在已经更改的“常量”值中。
Any workable answer is welcome but the ideal answer is one that can be setup once and not require any changes/maintenance when other code is modified.
任何可行的答案都是受欢迎的,但是理想的答案是可以设置一次,并且在修改其他代码时不需要任何更改/维护。
6 个解决方案