0

I have a third party web service. With VB.Net, one of the parameters of the function I'm using accepts an array of MyObject. So if I wrote the code below, SomeFunction would work as expected.

    Dim myArr(0) As MyObject
    SomeFunction(myArr)

Since myArr could hold many elements I wanted to create a different function that would allow me to pass in the relevant element (0,1,2,3,4....) into SomeFunction, rather than passing in 0 (in this case manually).

I'm not sure how to do this. Could someone help here?

2
  • 1
    Please elaborate on "that would allow me to pass in the relevant element into SomeFucntion." I am confused because you said SomeFunction takes an array, not a single element. Commented Jan 11, 2013 at 21:58
  • sure a little hard to explain but here goes. Using the above code works. In order for me to go through other elements i would have to write Dim myArr(1) As MyObject Dim myArr(2) As MyObject So what i thought was to create another function that would process the array elements and pass the relevant one to the function. The error i currently get if attempting my own way is 1-dimensional array of MyObjectt' cannot be converted to 'MyObject Commented Jan 11, 2013 at 22:13

1 Answer 1

2

I'm not sure I completely understand your question, but if you're trying to pass in a single value of your object rather than an array, have you tried something like:

Dim myArr1 As MyObject
Dim myArr1 As MyObject

   SomeFunction({myArr1})
   SomeFunction({myArr2})

Or, more specifically, in your case:

Dim myArr(100) As MyObject

   ... code ...
   SomeFunction({myArr(20)})

... Something along those lines??

I apologize if I didn't understand your question correctly.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.