Re: Array Function

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Kevin Spencer (kevin_at_DIESPAMMERSDIEtakempis.com)
Date: 01/04/05


Date: Tue, 4 Jan 2005 15:01:30 -0500

You're referencing "FieldArray" in your function, and for the life of me, I
can't see where you've created it. Perhaps it is Nothing?

In addition, a Function returns a value. Yours doesn't. That should take
care of the next question you would be posting.

-- 
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
Neither a follower nor a lender be.
"Rock" <rockisland@yahoo.com> wrote in message 
news:OCV2Tbp8EHA.2124@TK2MSFTNGP14.phx.gbl...
>I am getting an error:  "Object reference not set to an instance of an
> object." when trying to use a function that returns an array list.  Can I
> not do this, how would I set the instance of a public function???
>
> I have a global function FieldArray in Class 1:
>
> Public Function FieldArray(s1, s2) as arraylist
>            FieldArray.Add(s1)
>            FieldArray.Add(s2)
> End function
>
> which I call from my form:
>
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
>
>        Dim arrFields as new ArrayList
>        Dim cls as new Class1
>        arrFields = cls.FieldArray(str1, str2)
>
>    End Sub
>
> 


Relevant Pages