I'm reading a text file with entries like this:
I read in each line and call the sub Convert below:
I deal with everything as strings.
What I'm trying to do is parse the file, line-by-line, and "renumber" occurrences as above. The obvious problem is if (for example), 87 is converted to 331, it is later converted back to 87. I've thought about setting a flag and only doing the conversion is the flag isn't set but that doesn't work if the same line contains both 87 and 331, right?
Anyway, I just can't seem to wrap my head around how to deal with this. Help?
Code:
(1) 228 162 85 190 181
(2) 228 166 87 332 227 116 221 85
(3) 207 122 98
(4) 14
(5) 209 331
(6) 207 124 24
Code:
Private Sub Convert(ValueToConvert As String)
AR = Split(ValueToConvert, " ")
For A = 0 To UBound(AR)
If AR(A) = "87" Then AR(A) = "331"
If AR(A) = "88" Then AR(A) = "332"
If AR(A) = "89" Then AR(A) = "333"
If AR(A) = "331" Then AR(A) = "87"
If AR(A) = "332" Then AR(A) = "88"
If AR(A) = "333" Then AR(A) = "89"
What I'm trying to do is parse the file, line-by-line, and "renumber" occurrences as above. The obvious problem is if (for example), 87 is converted to 331, it is later converted back to 87. I've thought about setting a flag and only doing the conversion is the flag isn't set but that doesn't work if the same line contains both 87 and 331, right?
Anyway, I just can't seem to wrap my head around how to deal with this. Help?