Hi all
This is my first post. I`ve looked back at the previous array discussions and haven`t found an answer to my problem so apologies if I am re-asking something that has already been asked in the past.
I have the following function in a .net class:
Public Shared Function ReturnAll(ByVal odfpath As String) As String()
Dim ReturnArray(1) As String
Dim returntext As String = ""
Dim c() As String = Nothing
Dim i As Integer = 0
If IO.File.Exists(odfpath) = True Then
Dim sr As New StreamReader(odfpath)
Dim line As String = sr.ReadLine()
Do While sr.Peek <> -1
c = line.Split("=")
If c.GetUpperBound(0) = 1 Then
ReturnArray(i) = c(0)
i += 1
ReturnArray(i) = c(1)
i += 1
Return ReturnArray
c = Nothing
ReturnArray = Nothing
Exit Function
End If
line = sr.ReadLine
Loop
ReturnArray(0) = "ERROR1: NO Match Found"
Return ReturnArray
Else
ReturnArray(0) = "ERROR2: NO Match Found"
Return ReturnArray
End If
End Function
Basically, the function looks at a text file and reads in, splits, and enters into ReturnArray any line that looks like this: property = value
The function is being called from the main form like this:
TextBox4.Text = ReturnAll(TextBox2.Text)
The thing I cannot figure out is how to handle the array when it is returned back to the main form so that I can access both items in the array.
The array will always have 2 entries - the text before the = and the text after.
I have tried creating another array and having that call the ReturnAll function as so:
dim array(1) as string
array() = ReturnAll(TextBox2.Text)
but it just comes up with the following error, as does the main form code above: Value of type '1-dimensional array of String' cannot be converted to 'String'.
If anyone can help me solve this problem that would be greatly appreciated as i`ve been trying to get it work for 3 hours now and it is doing my head in! :-)
hermiod