I have a Global table that contains various values such as Default Insurance Cost, Fax Time Minimum, Fax Time Maximum, Email Invoice Delay Days, etc., which are used throughout my program.
The two main columns of the table are VariableName and VariableValue.
I have a global class in the program where I define the variables as Public Shared. Sample Here
I load the class in a loop as follows:
When I need one of the global variables I use this code.
This works, but is there a better way to load and/or use the values of these global settings?
I thought about just having the table in the Globals Class and having a procedure in the class that would find the correct record and return the value needed. I don't think this would take too much time as there are less than 100 records in the table.
Auguy
Sylvania/Toledo Ohio
The two main columns of the table are VariableName and VariableValue.
I have a global class in the program where I define the variables as Public Shared. Sample Here
Code:
Public Shared InsuranceCost as decimal = cdec(0.0)
Code:
dsGlobals = SelectGlobalData()
' Process All Rows
For Counter1 = 0 To dsGlobals.Tables(0).Rows.Count - 1
Select Case dsGlobals.Tables(0).Rows(Counter1).Item("VarName").ToString.Trim.ToUpper
Case "InsuranceCost".ToUpper
' Insurance Cost
Globals.InsuranceCost1 = CDec(dsGlobals.Tables(0).Rows(Counter1)("VarValue"))
Case "FaxTimeMinValue".ToUpper
' Fax Allowance in Minutes (Before Reporting Problem, Stop Reporting Problem)
Globals.FaxTimeMinValue = CInt(dsGlobals.Tables(0).Rows(Counter1)("VarValue"))
Case "FaxTimeMaxValue".ToUpper
Globals.FaxTimeMaxValue = CInt(dsGlobals.Tables(0).Rows(Counter1)("VarValue"))
Case "BolDelayDays".ToUpper
' Delay this many days before looking for BOL files
Globals.BolDelayDays = CInt(dsGlobals.Tables(0).Rows(Counter1)("VarValue"))
Case ....(More Here)
End Select
Next
Code:
InsuranceCost = Globals.InsuranceCost
I thought about just having the table in the Globals Class and having a procedure in the class that would find the correct record and return the value needed. I don't think this would take too much time as there are less than 100 records in the table.
Auguy
Sylvania/Toledo Ohio