Global Variables in Processbook VBA

Discussion created by OxleyCreek on May 24, 2011
Latest reply on May 25, 2011 by OxleyCreek

I have a display module with two subs and a global variable - startIndex. I set startIndex in the first sub and access it the second sub but the value is not retained when I get to the second sub. What am I doing wrong? Any advice on using global variables in Processbook VBA would be greatly appreciated !




Michael Jones

Public startIndex As Integer

Private Sub CommandButton1_Click()
Dim val As Value
Dim theTime As Date
theTime = Date + #4:00:00 AM#
If Now < theTime Then theTime = theTime - 1
Dim maxWidth As Integer
Dim smallGap As Integer
startIndex = Symbols.Count + 1
Dim bigGap As Integer


Private Sub CommandButton2_Click()
Dim startTime As Date
startTime = Date + #4:00:00 AM#
If Now < startTime Then startTime = startTime + 1
    Dim sym As Symbol
    Dim index As Integer
    index = (Now - startTime) * 48 + startIndex
    Set sym = Symbols.Item(index)
    sym.BackgroundColor = vbGreen
End Sub