Message 1 of 7
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I had one version of this working using ArrayList and a For Each loop.
This version tries to avoid the loop by using a keyed collection. But it seems "i" is not being set.
Why does this code not work? I'm sure it's something stoopid on my part, but I can't see it.
Class Clip
Property clipLeg1 As Double
Property clipLeg2 As Double
Property clipThickness As Double
Property clipDescription As String
Sub New(L1 As Double, L2 As Double, T As Double, D As String)
clipLeg1 = L1
clipLeg2 = L2
clipThickness = T
clipDescription = D
End Sub
End Class
Sub Main()
Dim ClipList As New Collection() 'items are accessable via "Key"
With ClipList
.Add(New Clip(1.75, 1.0, 0.125, "1-3/4 x 1 x 1/8 Angle"), "158262")
.Add(New Clip(2.0, 1.5, 0.125, "2 x 1-1/2 x 1/8 Angle"), "17338")
.Add(New Clip(2.0, 0.75, 0.125, "2 x 3/4 x 1/8 Angle"), "205621")
.Add(New Clip(1.5, 0.75, 0.125, "1-1/2 x 3/4 x 1/8 Angle"), "5137")
.Add(New Clip(2.0, 1.0, 0.125, "2 x 1 x 1/8 Angle"), "6844")
.Add(New Clip(1.0, 0.75, 0.125, "1 x 3/4 x 1/8 Angle"), "7385")
.Add(New Clip(1.5, 1.0, 0.125, "1-1/2 x 1 x 1/8 Angle"), "7613")
.Add(New Clip(0.75, 0.75, 0.125, "3/4 x 3/4 x 1/8 Angle"), "79a")
.Add(New Clip(1.0, 1.0, 0.125, "79g, 1 x 1 x 1/8 Angle"), "79g")
.Add(New Clip(1.25, 1.25, 0.125, "1-1/4 x 1-1/4 x 1/8 Angle"), "79t")
.Add(New Clip(1.5,1.5,0.125,"1-1/2 x 1-1/2 x 1/8 Angle"), "79v")
End With
'get value of selection parameter
Dim p = Parameter.Param("CLIP_TAG")
'get selection from ClipList
Dim i As Clip = ClipList(p.Value)
Parameter("CLIP_LEG1") = i.clipLeg1
Parameter("CLIP_LEG2") = i.clipLeg2
Parameter("CLIP_THK") = i.clipThickness
iProperties.Value("Project", "Description") = p.Value & ", " & i.clipDescription
Parameter.Param("CLIP_TAG").Comment = "L" &
CStr(i.clipLeg1) & " x " &
CStr(i.clipLeg2) & " x " &
CStr(i.clipThickness)
ThisApplication.ActiveDocument.Update
End Sub
Solved! Go to Solution.