Attribute VB_Name = "modStatusCode"
Public StatusCodeColorLevel  As String
Public StatusCodeColorLevelPrior As String

Global Const CodeRed = "Red"              'EMERGENCY!
Global Const CodeOrange = "Orange"          'Attention required
Global Const CodeYellow = "Yellow"          'Oops!
Global Const CodeGreen = "Green"            'Everything running
Global Const CodeBlue = "Blue"              'Magnetometer Free
Global Const CodeGrey = "Grey"              'No idea

Global Const ColorGrey = &H8000000C
Global Const ColorBlue = &HFFFF00
Global Const ColorGreen = &HFF00&
Global Const ColorYellow = &HFFFF&
Global Const ColorOrange = &H80FF&
Global Const ColorRed = &HFF&

Public Sub SetCodeLevel(newLevel As String, Optional withEmailUpdate = False)
    If newLevel = CodeRed Or newLevel = CodeOrange Or newLevel = CodeYellow Or newLevel = CodeGreen Or newLevel = CodeBlue Or newLevel = CodeGrey Then
        If StatusCodeColorLevel = CodeGreen Or StatusCodeColorLevel = CodeBlue Then
            StatusCodeColorLevelPrior = StatusCodeColorLevel
        ElseIf LenB(statuscolorlevelprior) = 0 Then
            StatusCodeColorLevelPrior = CodeBlue
        End If
        StatusCodeColorLevel = newLevel
        frmProgram.SetProgramCodeLevel newLevel
        If withEmailUpdate Then frmSendMail.StatusMonitorUpdate newLevel
    End If
End Sub

