- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello all,
I am aware of what Subs and Functions are, but not sure how to make this work like I'm intending, and I may totally have all this backwards as well. What I am trying to do is... I have a series of nested select cases that are happening for instance: Choose a size, choose a thickness, then choose a finish. Then inside of this, I have set parameters to define what components part numbers I need from CC to add for this particular selection. Then just below that, I thought I would call a function that is essentially a repeat set of instructions for placing the defined part numbers from CC, patterning, etc.
Once done, I may need to do this again, but for a different size and for a different finish. So, instead of copying and pasting a lot of redundant code for each finish and size, I thought...hmm Just use a function. Have the select case define what part numbers to use, then that will call the function and pass the part numbers to the function and then based on that it would run the function and place the components with the part numbers I need from CC that we set in the select case. I just don't know how to make this happen. I was hoping to just define part numbers in the select case and then the code for each size/finish is the same, just changing what parts are being used. Below is an example:
Sub main Select Case Size Case "10" Select Case Thickness Case "1/8" Select Case Finish Case "Plain" Dim part_1 = "123" Dim part_2 = "456" Dim part_3 = "789" Call My_Function Case "Galvanized"
Dim part_1 = "111"
Dim part_2 = "222"
Dim part_3 = "333"
Call My_Function Case "Painted" End Select Case "1/4" End Select Case "20" Case "30" End Select End Sub Function My_Function Components.AddContentCenterPart("", "whatever CC info here", part_1) Components.AddContentCenterPart("", "whatever CC info here", part_2) Components.AddContentCenterPart("", "whatever CC info here", part_3) End Function
Solved! Go to Solution.