从数据文件VB脚本读取下一行 [英] Reading next line from data file VB Script

查看:167
本文介绍了从数据文件VB脚本读取下一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取数据标签文件的下一行,但是因为有多行具有相同标签,所以它正在经历最后一行,但是我需要第一行。下面的示例标记文件。

I am trying to get the next line of data tag file, however because there are multiple lines with the same tag it is going through and taking the last one but I need the first one. Example tag file below.

Summary SA2100|7775555
Summary SUM100|9674555
Summary SUM100|8544555
Summary SUM100|8555554

从这开始需要8555554而不是7775555。

From this it is taking 8555554 and not 7775555.

我试图将第一行放在if条件中,并将字符串设置为下一行是否可能?

I was trying to put the first line in the if condition and set the string to be the next line is this possible ?

if Left(strLine, 14) = "Summary SA2100" Then
        strSummary = mid(strNextLine, 16, 7)
End If 

有没有办法使用StrNextLine或类似的东西?

Is there a way to use StrNextLine or something similar ?

谢谢

推荐答案

Set FSO = CreateObject("Scripting.FileSystemObject")  'create object to open file
Set txtFile = FSO.OpenTextFile("C:\test.txt")   'full path for your file

 Do while Not txtFile.AtEndOfStream 
    strLine = txtFile.ReadLine

    If InStr(1,strLine,"Summary SA2100",1) > 0 Then
      strNextLine=txtFile.ReadLine
        nxtLine= mid(strNextLine, 16, 7)
        Exit Do 
    End If
loop
   MsgBox "The First Line : "& mid(strLine,16,7) & vbcrlf & "The Next Line : " & nxtLine

这篇关于从数据文件VB脚本读取下一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆