vb如何读取文本文件中指定内容

2026年09月25日 22:10
有1个网友回答
网友(1):

哦,假设你的加密文件的路径是c:\1.txt,用以下代码读入变量进行操作。
dim
a()
as
string,r
as
integer

'全局变量,写在通用处
dim
t
as
string,i
as
integer

open
"c:\1.txt"
for
input
as
#1
while
not
eof(1)

'计算文件的行数
line
input
#1,t
i=i+1
wend
r=i
redim
a(i)
i=0
while
not
eof(1)

'将文件读入字符数组
line
input
#1,a(i)
i=i+1
wend
close
#1
现在数组a中的就是你的txt的内容了,按照你的算法对这些解密就好了,
写入的时候用这个
dim
i
as
integer
open
"c:\2.txt"
for
output
as
#1
for
i=0
to
r-1
print
#1,a(i)
next
close
#1
就将变量写入了。