Im trying to assign an array to global array in a for loop. I've spent many hours on this and have come up with nothing that works right.
I would greatly appreciate some help. Here is my code:
Public Class XMLCleanUp
Public splitoff() As String '// array holding the split off data
Public Function colors_Function(ByVal Inputfile() As String, ByVal count As Integer) As String
Dim x As Integer = 0 '//counter for the array
Dim w As Integer = 0 '//counter for the array
Dim aryVariable(x) As String '// array of the <color>
Dim aryText() As String '// set the counter in the string
aryText = Inputfile '// assigning the file to the array that will be written out.
Dim FILE_NAME2 As String = ("C:\colorsplitoff.txt")
Using writer As StreamWriter = New StreamWriter(FILE_NAME2)
For z = 0 To newstr_count - 1
If aryText(z).Trim = "<Color>" Then
Do Until aryText(z).Trim = "</Color>"
aryVariable(x) = (aryText(z), z) ' <----This is where Im trying to assign the array to a public array that is used in other functions
writer.WriteLine(aryText(z), z)
z = z + 1
splitoffcount = splitoffcount + 1
Loop
If aryText(z).Trim = "</Color>" Then
writer.WriteLine(aryText(z), z)
splitoffcount = splitoffcount + 1
End If
End If
Next z
End Using
Return newstr_count
End Function
I would greatly appreciate some help. Here is my code:
Public Class XMLCleanUp
Public splitoff() As String '// array holding the split off data
Public Function colors_Function(ByVal Inputfile() As String, ByVal count As Integer) As String
Dim x As Integer = 0 '//counter for the array
Dim w As Integer = 0 '//counter for the array
Dim aryVariable(x) As String '// array of the <color>
Dim aryText() As String '// set the counter in the string
aryText = Inputfile '// assigning the file to the array that will be written out.
Dim FILE_NAME2 As String = ("C:\colorsplitoff.txt")
Using writer As StreamWriter = New StreamWriter(FILE_NAME2)
For z = 0 To newstr_count - 1
If aryText(z).Trim = "<Color>" Then
Do Until aryText(z).Trim = "</Color>"
aryVariable(x) = (aryText(z), z) ' <----This is where Im trying to assign the array to a public array that is used in other functions
writer.WriteLine(aryText(z), z)
z = z + 1
splitoffcount = splitoffcount + 1
Loop
If aryText(z).Trim = "</Color>" Then
writer.WriteLine(aryText(z), z)
splitoffcount = splitoffcount + 1
End If
End If
Next z
End Using
Return newstr_count
End Function