Is it possible to declare a public variable in vba and assign a default value?

后端 未结 8 681
旧时难觅i
旧时难觅i 2020-12-09 01:33

I want to do this but it won\'t compile:

Public MyVariable as Integer = 123

What\'s the best way of achieving this?

8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-09 01:46

    You can define the variable in General Declarations and then initialise it in the first event that fires in your environment.

    Alternatively, you could create yourself a class with the relevant properties and initialise them in the Initialise method

提交回复
热议问题