VB 按行读文件,只将指定字符的这一行及它的下一行写入文件

来源:百度知道 编辑:UC知道 时间:2024/06/30 16:31:14
文件为:A
甲甲甲
B
乙乙乙
C
丙丙丙
……
我只想读出“C”这一行 ,以及它的下一行“丙丙丙”,读出后存入新文件。应该怎么编程?谢谢
现在改成: 遇到逢A, 逢C都要读这一行及它的下一行 怎么改。。。。我刚才试了半天 只能读出满足一个条件的

dim Str as string
dim StrC as string
dim StrCC as string
open XXXXXX for input as #1
do while not eof(1)
line input #1,str
if str="C" then
strc=str
line input #1,strcc
open XXXXXX2 for output as #2
print #2,strc
print #2,strcc
close #2
exit do
end if
loop
close

Open "文件1.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, a
if left(a,1)="C"
line input #1,b
open "文件2.txt" for output as #2
print #2, a
print #2, b
close #2

'添加需执行命令
Loop
Close #1

Dim a$
Open "TESTFILE" For Input As #1
Do While Not EOF(1)
Line Input #1, a
text1=a '如果需要保留text1中的内容,请使用:text1=text1 & a & vbcrlf
'添加需执行命令
Loop

也是百度知道上的代码,你可以参考一下。
Dim a$
Dim firstLine=""
Dim secondLine=""
Dim firstFinis