用VB对记事本里的数据进行分离

来源:百度知道 编辑:UC知道 时间:2024/06/07 00:54:21
我想用VB把记事本里的数据(此文件中的行数不固定)进行分离,具体要求是:记事本里的前8行数据分别输出到A.txt和B.txt的记事本里,9—13行数据输出到A.txt里,14—18行数据输出到B.txt里,19—23行数据输出到A.txt里,24—28行数据输出到B.txt里,按照此规律依次类推。

谢谢!

private sub command1_click()
dim s as string
dim n as long
open "***\*.txt" for output as #1 '文件路径和文件名自己修改
open "***\a.txt" for input as #2
open "***\b.txt" for input as #3
do while not eof(1)
input #1,s
n=n+1
if n<=8 then
print #2,s
print #3,s
elseif (n-9) mod 10 <5 then
print #2,s
else
print #3,s
end if
loop
close #1
close #2
close #3
end sub