dim str_search '需要查找的字串 dim num_n '第N行 dim dataA '需要赋值的变量 dim fileroot '文件路径 str_search="???" '赋值 num_n=100 dataA="" fileroot="c:\1.txt" Open fileroot For Input As #1 Do While b<>"ENDSEC" Line Input #1, b if b=str_search then for i=1 to num_n Line Input #1, b next i dataA=b end if Loop 没测试过。如果你的第N行超过了“ENDSEC”的那行或者超出文件结尾的话也许会出错。 自己加个逻辑判断就可以了。