Run multiple array lists with ability to skip to next

Run multiple array lists with ability to skip to next

bbrumfield
Advocate Advocate
322 Views
2 Replies
Message 1 of 3

Run multiple array lists with ability to skip to next

bbrumfield
Advocate
Advocate

I have several array lists that do function as long as you make a selection. If you skip there is a failure message that says :

"Error in rule: Stock Sheet Material Stock Code List, in document: CadTalk_Test_3.ipt

Index was outside the bounds of the array."

 

As an example, I'd like to skip past Aluminum and select Galvanized or Steel etc. Which ever material in this case that is selected should create a custom property named "material stock code 1"

 

Dim oDoc As Document = ThisDoc.Document

Dim CustTypeALU As New ArrayList
CustTypeALU.Add(".063, Sheet, Aluminum, 5052-H32, 60.00 x 120.00 | ME-CRS-0003")
CustTypeALU.Add(".125, Sheet, Aluminum, 5052-H32, 60.00 x 120.00 | ME-CRS-0005")
CustTypeALU.Add(".090, Sheet, Aluminum, 5052-H32, 60.00 x 120.00 | ME-CRS-0007")
CustTypeALU.Add(".190, Sheet, Aluminum, 5052-H32, 60.00 x 120.00 | ME-CRS-0009")
CustTypeALU.Add(".050, Sheet, Aluminum, 5052-H32, 60.00 x 120.00 | ME-CRS-0013")
CustTypeALU.Add(".030, Sheet, Aluminum, 5052-H32, 60.00 x 120.00 | ME-CRS-0016")
CustTypeALU.Add(".080, Sheet, Aluminum, 5052-H32, 60.00 x 120.00 | ME-CRS-0017")

Dim oSelSheetMaterialStockCodeOpt1 As String = InputListBox("Select Sheet Material Stock Code", 
	CustTypeALU, oSheetMaterialStockCodeOpt1, Title := "ALU Sheet Selection", _
	ListName := "ALU Sheet Stock Code")

sSplit = Split(oSelSheetMaterialStockCodeOpt1, "|")
oDesc = sSplit(0) 
oPN = sSplit(1) 

'if this custom property doesn't exist, this next line will also create it if needed (no error shown)
iProperties.Value("Custom", "Material Stock Code 1") = oPN

MsgBox(iProperties.Value("Custom", "Material Stock Code 1") )

Dim CustTypeGALV As New ArrayList
CustTypeGALV.Add("16GA, Sheet, Galvanneal Steel, 60.00 x 120.00 | ME-GALN-0001")
CustTypeGALV.Add("18GA, Sheet, Galvanneal Steel, 60.00 x 120.00 | ME-GALN-0002")
CustTypeGALV.Add("22GA, Sheet, Galvanneal Steel, 60.00 x 120.00 | ME-GALN-0003")
CustTypeGALV.Add("14GA, Sheet, Galvanized Steel, 60.00 x 120.00 | ME-GALV-0001")
CustTypeGALV.Add("16GA, Sheet, Galvanized Steel, 60.00 x 120.00 | ME-GALV-0002")
CustTypeGALV.Add("18GA, Sheet, Galvanized Steel, 60.00 x 120.00 | ME-GALV-0003")
CustTypeGALV.Add("24GA, Sheet, Galvanized Steel, 60.00 x 120.00 | ME-GALV-0004")

Dim oSelSheetMaterialStockCodeOpt2 As String = InputListBox("Select Sheet Material Stock Code", 
	CustTypeGALV, oSheetMaterialStockCodeOpt2, Title := "GALV Sheet Selection", _
	ListName := "GALV Sheet Stock Code")

sSplit = Split(oSelSheetMaterialStockCodeOpt2, "|")
oDesc = sSplit(0) 
oPN = sSplit(1) 

'if this custom property doesn't exist, this next line will also create it if needed (no error shown)
iProperties.Value("Custom", "Material Stock Code 1") = oPN

MsgBox(iProperties.Value("Custom", "Material Stock Code 1") )

Brent

 

0 Likes
Accepted solutions (1)
323 Views
2 Replies
Replies (2)
Message 2 of 3

A.Acheson
Mentor
Mentor
Accepted solution

You can check the string value coming from the the input list box selection. Many ways to write this, check if it is Nothing, check if it has an empty string, or use the string function to return a boolean value. 

 

If oSelSheetMaterialStockCodeOpt2 Is Nothing Then
MsgBox("Nothing Selected")
Else MsgBox(oSelSheetMaterialStockCodeOpt1) End If

 

If oSelSheetMaterialStockCodeOpt1 = Nothing Then 
   MsgBox("Nothing Selected")
Else
MsgBox(oSelSheetMaterialStockCodeOpt1) End If
If oSelSheetMaterialStockCodeOpt1 = "" Then 
    MsgBox("Nothing Selected")
Else
MsgBox(oSelSheetMaterialStockCodeOpt1) End If
If String.IsNullOrEmpty(oSelSheetMaterialStockCodeOpt1) = True Then 
MsgBox("Nothing Selected") Else
MsgBox(oSelSheetMaterialStockCodeOpt1)
End If

 

 

 

String Check Code

Dim oDoc As Document = ThisDoc.Document

Dim CustTypeALU As New ArrayList
CustTypeALU.Add(".063, Sheet, Aluminum, 5052-H32, 60.00 x 120.00 | ME-CRS-0003")
CustTypeALU.Add(".125, Sheet, Aluminum, 5052-H32, 60.00 x 120.00 | ME-CRS-0005")
CustTypeALU.Add(".090, Sheet, Aluminum, 5052-H32, 60.00 x 120.00 | ME-CRS-0007")
CustTypeALU.Add(".190, Sheet, Aluminum, 5052-H32, 60.00 x 120.00 | ME-CRS-0009")
CustTypeALU.Add(".050, Sheet, Aluminum, 5052-H32, 60.00 x 120.00 | ME-CRS-0013")
CustTypeALU.Add(".030, Sheet, Aluminum, 5052-H32, 60.00 x 120.00 | ME-CRS-0016")
CustTypeALU.Add(".080, Sheet, Aluminum, 5052-H32, 60.00 x 120.00 | ME-CRS-0017")

Dim oSelSheetMaterialStockCodeOpt1 As String = InputListBox("Select Sheet Material Stock Code", 
	CustTypeALU, oSheetMaterialStockCodeOpt1, Title := "ALU Sheet Selection", _
	ListName := "ALU Sheet Stock Code")

If oSelSheetMaterialStockCodeOpt1 = Nothing Then 'can also use "" as an empty string instead of Nothing
Else
	sSplit = Split(oSelSheetMaterialStockCodeOpt1, "|")
	oDesc = sSplit(0) 
	oPN = sSplit(1) 

	'if this custom property doesn't exist, this next line will also create it if needed (no error shown)
	iProperties.Value("Custom", "Material Stock Code 1") = oPN

	MsgBox(iProperties.Value("Custom", "Material Stock Code 1") )
End If
Dim CustTypeGALV As New ArrayList
CustTypeGALV.Add("16GA, Sheet, Galvanneal Steel, 60.00 x 120.00 | ME-GALN-0001")
CustTypeGALV.Add("18GA, Sheet, Galvanneal Steel, 60.00 x 120.00 | ME-GALN-0002")
CustTypeGALV.Add("22GA, Sheet, Galvanneal Steel, 60.00 x 120.00 | ME-GALN-0003")
CustTypeGALV.Add("14GA, Sheet, Galvanized Steel, 60.00 x 120.00 | ME-GALV-0001")
CustTypeGALV.Add("16GA, Sheet, Galvanized Steel, 60.00 x 120.00 | ME-GALV-0002")
CustTypeGALV.Add("18GA, Sheet, Galvanized Steel, 60.00 x 120.00 | ME-GALV-0003")
CustTypeGALV.Add("24GA, Sheet, Galvanized Steel, 60.00 x 120.00 | ME-GALV-0004")

Dim oSelSheetMaterialStockCodeOpt2 As String = InputListBox("Select Sheet Material Stock Code", 
	CustTypeGALV, oSheetMaterialStockCodeOpt2, Title := "GALV Sheet Selection", _
	ListName := "GALV Sheet Stock Code")
If oSelSheetMaterialStockCodeOpt2 = Nothing Then
Else
sSplit = Split(oSelSheetMaterialStockCodeOpt2, "|")
oDesc = sSplit(0) 
oPN = sSplit(1) 

'if this custom property doesn't exist, this next line will also create it if needed (no error shown)
iProperties.Value("Custom", "Material Stock Code 1") = oPN

MsgBox(iProperties.Value("Custom", "Material Stock Code 1")) 
End If

 

 

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 3 of 3

bbrumfield
Advocate
Advocate

Hi A.Acheson,

 

Thank you! Worked exactly as needed.

 

Brent

0 Likes