Public or Constant?

Viewed 770

I would like to declare kind of global variables. What I want to do is initialize these variables, then use them in macros, and change their values in other macros.

I started to write it as public variables:

Option Explicit
'definition of global variables
Public r_start As Integer
Public r_end As Integer
Public c_little As Integer
Public c_big As Integer
Public c_sel_start As Integer
Public c_sel_end As Integer
Public c_data_start As Integer
Public c_data_end As Integer

Public Sub Init_Globals()
' Access global variable initialization
    r_start = 20
    r_end = 833
    c_little = 6
    c_big = 5
    c_sel_start = 1
    c_sel_end = 4
    c_data_start = 11
    c_data_end = 101
End Sub

The problem here is that I have to call Sub_Init_Globals() in each of my SubProcedure, and so if I want to change the initial values of my global variables inside other SubProcedures, those changes won't be made.

Do you know a way to create such variables ?

2 Answers
Public Const YourVariableName as Integer = 1 

(or any other type or value of course) at the top of any user module seems to do the trick.

Related