VB.NET - Array of strings in vb net - Asked By L K on 10-May-06 12:33 AM

We are using an array of strings.

Dim Str1() as String  

Str1= Split(Source,",")
' Source is a String,that is declared  and populated with values in a different function

The problem here is that the array Str1 retains its contents durings the next call of the function too ! 

Thus when it is filled with new values some of the old values remain!


First run:

Next run:

-----whereas, it should be Str1={"7","8"}

-----------Any inputs on this issue??

Thanx :)
Asked By Shallu Gupta on 10-May-06 12:46 AM
Declare Array Local to the function.

ReDim - Asked By F Cali on 10-May-06 10:19 AM

Instead of the Dim, you can use ReDim to reinitialize your array:

ReDim Str1() as String
Str1= Split(Source,",")