Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27353

Using enum to determine actions

$
0
0
I want to use the Enum value passed to the class to determine which subs are called. More than one sub can execute. I have the Enum set up so nothing can ever be the same I just need to figure out how to get it to do whatever subs/functions it needs to do. I don't want to hard code anything which is causing me the problem. I might want to add another "LogType" and want to add it to the enum and maybe another line of code, not redo everything. Any ideas:

Code:

Public Class AppLogger

    Private _loggerType As Int32

    Public Enum LoggerTypeEnum As Int32
        EventLog = 1
        TextFile = 2
        XmlFile = 4
    End Enum

    Public Sub New(ByVal loggerType As LoggerTypeEnum)
        _loggerType = loggerType
        ProcessLogs()

    End Sub


    Private Sub ProcessLogs()
        Dim arrEnums() As Int32 = [Enum].GetValues(GetType(LoggerTypeEnum))

        Dim currentCount As Int32 = arrEnums(arrEnums(arrEnums.Length - 1))
        For i As Int32 = arrEnums.Length - 1 To 0 Step -1


            End If

        Next



    End Sub

End Class

Oh and if I want two different methods to log I can call: AppLogger(LoggerTypeEnum.EventLog + LoggerTypeEnum.XmlFile) which equals 5



I've been programming for 15 years with companies but haven't did anything like this which I thought would be easy. Just like unix file permissions 1+2+4 = 7. Maybe I'm just having a brain fart tonight.

NOTE: This is just a test class it's no where near complete. Just trying to get something. The logging to different things is a breeze.

Viewing all articles
Browse latest Browse all 27353

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>