- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm converting a multi-dimensional chart into a data table and am trying to better consolidate my code to be friendly for reading/comparing as well as reduce the code footprint required, but I'm getting a bit lost on code format/syntax here and was hoping someone could help me out. I'll explain in depth in case someone else is trying to accomplish this same task and may also find this helpful in their search.
I'm trying to take this supplied printed table and store it in my iLogic code as a Matrix/Array.
Column A (17 row entries) is my bolt size
Column B (12 column entries) is my material thickness
Row C (2 rows) are my desired distance values I want to look up
I have been able to digitize this table with the following code...
Dim oHoleChart(17, 12, 2) As Double '(17)Bolt Size / (12)Material Thickness / (2)Distances C & E' MyList = New Double(){1 + (1 / 8), 1 + (5 / 16), 1 + (3 / 8), 1 + (11 / 16), 2 + (1 / 16), 2 + (1 / 8), 2 + (3 / 16), 2 + (11 / 16), 3 + (9 / 16), 4 + (1 / 16), 4 + (9 / 16), 5 + (9 / 16)} For i = 1 To 12 '1/4 inch bolts oHoleChart(1, i, 1) = MyList(1, i-1) oHoleChart(1, i, 2) = 1 / 2 Next MyList = New Double(){1 + (1 / 4), 1 + (7 / 16), 1 + (1 / 2), 1 + (13 / 16), 2 + (3 / 16), 2 + (1 / 4), 2 + (5 / 16), 2 + (13 / 16), 3 + (11 / 16), 4 + (3 / 16), 4 + (11 / 16), 5 + (11 / 16)} For i = 1 To 12 '3/8 inch bolts oHoleChart(2, i, 1) = MyList(i-1) oHoleChart(2, i, 2) = 1 / 2 Next . . .
So if I wanted to lookup the "C" value for a 1/4" bolt on 9/16 material I could use oHoleChart(1, 6, 1) to find a value of 2.125
What I really want is to do this in a pair of nested For/Next loops so I can group all the "MyList" definitions together so it's friendlier to read against this printed Table and the 2nd loop would reduce my coding. I can't quite figure the format, but here's the jist of what I'm wanting.
Dim oHoleChart(17, 12, 2) As Double '(17)Bolt Size / (12)Material Thickness / (2)Distances C & E' Dim MyList1(17, {}) As Double 'This doesn't work 'Dim MyList(17) 'This doesn't work 'Dim MyList(17, ()) 'This doesn't work MyList1(1, {}) = New Double() {1 + (1 / 8), 1 + (5 / 16), 1 + (3 / 8), 1 + (11 / 16), 2 + (1 / 16), 2 + (1 / 8), 2 + (3 / 16), 2 + (11 / 16), 3 + (9 / 16), 4 + (1 / 16), 4 + (9 / 16), 5 + (9 / 16) } MyList1(2, {}) = New Double() {1 + (1 / 4), 1 + (7 / 16), 1 + (1 / 2), 1 + (13 / 16), 2 + (3 / 16), 2 + (1 / 4), 2 + (5 / 16), 2 + (13 / 16), 3 + (11 / 16), 4 + (3 / 16), 4 + (11 / 16), 5 + (11 / 16) } . . . MyList1(17, {}) = New Double() {3 + (9 / 16), 3 + (3 / 4), 3 + (13 / 16), 4 + (1 / 8), 4 + (1 / 2), 4 + (9 / 16), 4 + (5 / 8), 5 + (1 / 8), 6, 6 + (1 / 2), 7, 8 } MyList2 = New Double() {1 / 2, 1 / 2, 3 / 4 , ...} 'value changes only for bolt size For j = 1 To 17 For i = 1 To 12 '1/4 inch bolts oHoleChart(j, i, 1) = MyList1(j, i-1) oHoleChart(j, i, 2) = MyList2(i-1) Next Next
Is there a workflow here or is my original concept the only way to go?

Solved! Go to Solution.