如何用vb来读写操作txt文档,然后将处理结果输入到另外的txt文件中?
如下图所示,六个txt文件,一二行分别表示列数和行数,想请教怎么分别读文件中的数据赋予六个数组,然后对数组进行比较,核心部分处理数据的会写了,但是对于这个读数据并赋给六个...
如下图所示,六个txt文件,一二行分别表示列数和行数,想请教怎么分别读文件中的数据赋予六个数组,然后对数组进行比较,核心部分处理数据的会写了,但是对于这个读数据并赋给六个数组和将比较后的数据重新输入新的txt文件中不怎么会?望高手指点!(3456行数据可以不用管它)
ncols 7179
nrows 4641
xllcorner 419339.3161289
yllcorner 260193.78187478
cellsize 10
NODATA_value -9999
-9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 展开
ncols 7179
nrows 4641
xllcorner 419339.3161289
yllcorner 260193.78187478
cellsize 10
NODATA_value -9999
-9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 展开
2个回答
展开全部
'假如您的六个文本路径分别为
' D:\1.txt 、D:\2.txt 、D:\3.txt 、D:\4.txt 、D:\5.txt 、D\:6.txt
Private Sub Command1_Click()
Dim T(1 To 6) As String
'读取1.text 到 6.txt 文本,将文本内容赋值到T数组
For i = 1 To 6
Open "D:\" & i & ".txt" For Binary As #1
T(i) = Input(LOF(1), 1)
Close #1
Next
'此处您可以根据需要更改比较数组(也就是txt文件)内容
'保存T数组值到 D:\1(改).txt 、D:\2(改).txt 、D:\3(改).txt 、D:\4(改).txt 、D:\5(改).txt 、D\:6(改).txt 也可以使用同样的目录如 D:\1.txt 进行替换原先的 D:\1.txt 文件。
For i = 1 To 6
Open "D:\" & i & "(改).txt" For Output As #1
Print #1, T(i)
Close #1
Next
Command1.Caption = "保存完成"
End Sub
'写得很辛苦,请采纳,谢谢!
' D:\1.txt 、D:\2.txt 、D:\3.txt 、D:\4.txt 、D:\5.txt 、D\:6.txt
Private Sub Command1_Click()
Dim T(1 To 6) As String
'读取1.text 到 6.txt 文本,将文本内容赋值到T数组
For i = 1 To 6
Open "D:\" & i & ".txt" For Binary As #1
T(i) = Input(LOF(1), 1)
Close #1
Next
'此处您可以根据需要更改比较数组(也就是txt文件)内容
'保存T数组值到 D:\1(改).txt 、D:\2(改).txt 、D:\3(改).txt 、D:\4(改).txt 、D:\5(改).txt 、D\:6(改).txt 也可以使用同样的目录如 D:\1.txt 进行替换原先的 D:\1.txt 文件。
For i = 1 To 6
Open "D:\" & i & "(改).txt" For Output As #1
Print #1, T(i)
Close #1
Next
Command1.Caption = "保存完成"
End Sub
'写得很辛苦,请采纳,谢谢!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询