私は整数データのテキストファイルを持っています。つまり、
00201305170013333
01201305170013333
02201305170013333
各行の 2 番目と 3 番目の位置を、各行の 6 番目と 7 番目のインデックスと交換したいと考えています。スワップ手法を適用しましたが、どういうわけか新しい文字列が更新されません。
コードを見てください:
Imports System
Imports System.IO
Imports System.Collections
Module Module1
Sub Main()
Dim reader As StreamReader = New StreamReader("input.txt")
Dim sLine As String = ""
Dim arrText As New ArrayList()
Do
sLine = reader.ReadLine()
If Not sLine Is Nothing Then
arrText.Add(sLine)
End If
Loop Until sLine Is Nothing
reader.Close()
Dim varReplace As Integer
Dim arrTextToString(arrText.Count) As String
For varReplace = 0 To arrText.Count - 1
arrTextToString(varReplace) = arrText(varReplace).ToString()
Next
Dim rep As Integer
For rep = 0 To arrText.Count - 1
Dim two, three, mix1, mix2, six, seven As String
Dim str = arrText(rep)
two = (str(2))
three = (str(3))
six = (str(6))
seven = (str(7))
mix1 = two
two = six
six = mix1
mix2 = three
three = seven
seven = mix2
str(2) = two.ToString()
str(3) = three.ToString()
str(6) = six.ToString()
str(7) = seven.ToString()
Console.Write(two)
Console.Write(three)
Console.Write(" ")
Console.Write(six)
Console.Write(seven)
Console.Write(" ")
Console.WriteLine(str)
Next
'For pri = 0 To arrText.Count - 1
'Console.WriteLine(arrTextToString(pri))
'Next
Console.ReadLine()
End Sub
End Module