Hello,
I have been programming for past few months and find it quite fun. I have come across a problem that I can not find an answer to. How do I assign a dynamic string array to a fixed string array?
What I have done is created a file, wrote to the file, and, using the code below, read from the file. Each line in the file is assigned to an array position and the counter is increased for each line. The array is then sorted and displayed in a list box.
mArray is not declared in this code because it is a module level variable that I use in other procedures and functions.
As mentioned earlier I have to take the dynamic array and assign it to an array(24).
Here is my code:
Dim index As Integer = 0
Dim lineoftext As String = ""
Using sr As New System.IO.Strea mReader("File_O f_Names")
While Not sr.EndOfStream
lineoftext = sr.ReadLine
If lineoftext <> "" Then
ReDim Preserve mArray(index)
mArray(index) = lineoftext
index = index + 1
mintItemCount = index
End If
End While
sr.Close()
End Using
Array.Sort(mArr ay)
For Each s As String In mArray
lstDisplaySorte dNames.Items.Ad d(s)
Next
Warmest Regards,
Rich
I have been programming for past few months and find it quite fun. I have come across a problem that I can not find an answer to. How do I assign a dynamic string array to a fixed string array?
What I have done is created a file, wrote to the file, and, using the code below, read from the file. Each line in the file is assigned to an array position and the counter is increased for each line. The array is then sorted and displayed in a list box.
mArray is not declared in this code because it is a module level variable that I use in other procedures and functions.
As mentioned earlier I have to take the dynamic array and assign it to an array(24).
Here is my code:
Dim index As Integer = 0
Dim lineoftext As String = ""
Using sr As New System.IO.Strea mReader("File_O f_Names")
While Not sr.EndOfStream
lineoftext = sr.ReadLine
If lineoftext <> "" Then
ReDim Preserve mArray(index)
mArray(index) = lineoftext
index = index + 1
mintItemCount = index
End If
End While
sr.Close()
End Using
Array.Sort(mArr ay)
For Each s As String In mArray
lstDisplaySorte dNames.Items.Ad d(s)
Next
Warmest Regards,
Rich
Comment