dan_l
Active Member
So---I've got a coding problem. I've got a solution. I'm looking for a second opinion if this is the right way to handle it, or if there's a better way:
The set up:
-It's access. The code lives in a class.
-The overall process is:
1) Feed the class a bunch of parameters
2) A function feeds a those parameters into a test multiple times
3) The results of the tests are logged in a table
4) The test results are queried for some optimum results
5) The optimum results are fed to another table
-The part I'm looking for advice on is 2.
-The practical question: I've got materials that can be various sizes. I have height, width, length. I've got 2 different sized containers and the dimensions of those containers.
-It all works fine as is, but I've got an itch that there's probably a better way to handle this function.
I'm feeding HLW of the material generically into the class because it doesn't really matter. I just identify them as 1,2, or 3. I test each of the dimensions against fixed values of the "bin"/container Height, Length, Width.
Like I say, it works just fine as is, it's just wordy code. I feel like there's probably another way to handle this I just don't know what it is. I wonder if it could be hashed out simpler with an array or something.
The set up:
-It's access. The code lives in a class.
-The overall process is:
1) Feed the class a bunch of parameters
2) A function feeds a those parameters into a test multiple times
3) The results of the tests are logged in a table
4) The test results are queried for some optimum results
5) The optimum results are fed to another table
-The part I'm looking for advice on is 2.
-The practical question: I've got materials that can be various sizes. I have height, width, length. I've got 2 different sized containers and the dimensions of those containers.
-It all works fine as is, but I've got an itch that there's probably a better way to handle this function.
Code:
Private Sub TestDimensions()
'small bin tests
Call SingleTest(Me.MatDim1, Me.MatDim2, Me.MatDim3, Me.SmallBinHeight, Me.SmallBinLength, Me.SmallBinWidth, Me.InternalID & "-" & "SB" & "-" & "123")
Call SingleTest(Me.MatDim1, Me.MatDim3, Me.MatDim2, Me.SmallBinHeight, Me.SmallBinLength, Me.SmallBinWidth, Me.InternalID & "-" & "SB" & "-" & "132")
Call SingleTest(Me.MatDim2, Me.MatDim1, Me.MatDim3, Me.SmallBinHeight, Me.SmallBinLength, Me.SmallBinWidth, Me.InternalID & "-" & "SB" & "-" & "213")
Call SingleTest(Me.MatDim2, Me.MatDim3, Me.MatDim1, Me.SmallBinHeight, Me.SmallBinLength, Me.SmallBinWidth, Me.InternalID & "-" & "SB" & "-" & "231")
Call SingleTest(Me.MatDim3, Me.MatDim1, Me.MatDim2, Me.SmallBinHeight, Me.SmallBinLength, Me.SmallBinWidth, Me.InternalID & "-" & "SB" & "-" & "312")
Call SingleTest(Me.MatDim3, Me.MatDim2, Me.MatDim1, Me.SmallBinHeight, Me.SmallBinLength, Me.SmallBinWidth, Me.InternalID & "-" & "SB" & "-" & "321")
'large bin tests
Call SingleTest(Me.MatDim1, Me.MatDim2, Me.MatDim3, Me.LargeBinHeight, Me.LargeBinLength, Me.LargeBinWidth, Me.InternalID & "-" & "LB" & "-" & "123")
Call SingleTest(Me.MatDim1, Me.MatDim3, Me.MatDim2, Me.LargeBinHeight, Me.LargeBinLength, Me.LargeBinWidth, Me.InternalID & "-" & "LB" & "-" & "132")
Call SingleTest(Me.MatDim2, Me.MatDim1, Me.MatDim3, Me.LargeBinHeight, Me.LargeBinLength, Me.LargeBinWidth, Me.InternalID & "-" & "LB" & "-" & "213")
Call SingleTest(Me.MatDim2, Me.MatDim3, Me.MatDim1, Me.LargeBinHeight, Me.LargeBinLength, Me.LargeBinWidth, Me.InternalID & "-" & "LB" & "-" & "231")
Call SingleTest(Me.MatDim3, Me.MatDim1, Me.MatDim2, Me.LargeBinHeight, Me.LargeBinLength, Me.LargeBinWidth, Me.InternalID & "-" & "LB" & "-" & "312")
Call SingleTest(Me.MatDim3, Me.MatDim2, Me.MatDim1, Me.LargeBinHeight, Me.LargeBinLength, Me.LargeBinWidth, Me.InternalID & "-" & "LB" & "-" & "321")
End Sub
I'm feeding HLW of the material generically into the class because it doesn't really matter. I just identify them as 1,2, or 3. I test each of the dimensions against fixed values of the "bin"/container Height, Length, Width.
Like I say, it works just fine as is, it's just wordy code. I feel like there's probably another way to handle this I just don't know what it is. I wonder if it could be hashed out simpler with an array or something.