Message 1 of 2
Multivalue parameter arrayList throwing error when assigning an array
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi there!
I'm getting an "Object reference not set to an instance of an object." error when attempting to assign an array to a multivalue parameter.
The multivalue parameter is "test" and the array I'm attempting to assign to the "test" parameter is the form array.
I've attempted to:
- simply assign the materialStyle array
- populate the formArray using the "add" function with the materialStyle array
- directly assign the materialStyle array TO the formArray
I'm simply not good enough to figure out what I am doing wrong.
Dave
AddReference "System.Linq" AddReference "System.Xml" AddReference "System.Xml.Linq" AddReference "System.Core" Imports System.Linq Imports System.Xml.Linq Imports System.Xml.Schema Imports System.Xml Sub Main Dim feedXML As XDocument Dim xmlDocName As String = "C:\Users\drouthier\Desktop\sheetmetalrules.xml" feedXML = XDocument.Load(xmlDocName) materialStyle = xmlFeedFilter(feedXML, "MaterialStyle") Dim formArray As New ArrayList() formArray.clear For x = 0 To UBound(materialStyle) formArray.add (materialStyle(x)) Next x MultiValue.List("test") = formArray End Sub Public Function xmlFeedFilter(feedXML As Object, attributeName As String) Dim x As Integer Dim z As Integer Dim objectArray(0) As String For Each oElement As XElement In feedXML.Descendants() For Each oAttribute As XAttribute In oElement.Attributes() If oAttribute.Value = attributeName z = 0 For x = 0 To UBound(objectArray) If UBound(objectArray) = 0 Then Exit For Else If objectArray(x) = oElement Then z = 1 Exit For End If End If Next x If z = 0 Then objectArray(UBound(objectArray)) = oElement ReDim Preserve objectArray(UBound(objectArray) + 1) End If End If Next oAttribute Next oElement BubbleSortAscending(list:= objectArray) xmlFeedFilter = objectArray End Function Public Sub BubbleSortAscending(list() As Object) ' Sorts an array using bubble sort algorithm ' Ascending ' perform the call from the main as ' BubbleSort (list:=array) Dim First As Long, Last As Long Dim i As Long, j As Long Dim Temp As Object First = LBound(list) Last = UBound(list) For i = First To Last - 1 For j = i + 1 To Last If list(i) > list(j) Then Temp = list(j) list(j) = list(i) list(i) = Temp End If Next j Next i End Sub