我有一个整数数据的文本文件,即
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