VB中读取TXT文件的问题
来源:百度知道 编辑:UC知道 时间:2024/05/22 17:55:31
dim Filename,Users(),Passs(),ls,tmp
redim users(0),passs(0)
ls=0
filename="c:\a.txt"'密码文件--最好先加密
open Filename for input as #1
do while not eof(1)
line input #1,tmp
if trim(tmp)="" then goto nxt else
tmp=trim(tmp) '去处空行的,如果允许空用户名、密码,可以去掉此行
ls=ls+1
if int(ls/2)=ls/2 then
redim Preserve Passs(ubound(passs)+1)
Passs(ubound(passs)+1)=tmp
else
redim Preserve users(ubound(users)+1)
users(ubound(users)+1)=tmp
end if
nxt:
loop
close
for fo=1 to ubound(users)
if users(fo)=text1.text then goto Allo
'不分大小写if lcase(users(fo))=lcase(text1.text) then goto Allo
next
msgbox "No User"
end
allo:
if passs(fo)<>text1.text then msgbox "ErrPassWord":end
'不分大小写if lcase(passs(fo))<>lcase(text1.text) then msgbox "ErrPassWord":end
msgbox "Yes"
附:加、解密函数 运行一次加密、再运行一