匹配一行并从中返回第4行 [英] match a line and return the 4th line from it
本文介绍了匹配一行并从中返回第4行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要使用VB访问文本文件并匹配"变量名称:Fcst_Wk"行。并返回它下面的第4行并将其分配给变量。即我需要"变量值:Wk2"这一行。并将其分配给变量。文件内容如下:
变量名称:CurrScenario
服务器名称:chnveltss04
申请名称:Plan_UAT
数据库名称:
变量值:LE_Wk1
变量名称:Fcst_Mth
服务器名称:chnveltss04
应用程序名称:Plan_UAT
数据库名称:
变量值: 7月$
变量名称:Fcst_Wk
服务器名称:chnveltss04
应用程序名称:Plan_UAT
数据库名称:
变量值:Wk2
变量名称:NextScenario
服务器名称:chnveltss04
申请名称:Plan_UAT
数据库名称:
变量值:LE_Wk2
感谢您的帮助。
问候,
Ragav。
Hi,
I need to access a text file using VB and match the line "Variable name : Fcst_Wk" and return the 4th line below it and assign it to a variable. i.e i need the line "Variable value : Wk2" and assign it to a variable. The content of the file is as below.
Variable name : CurrScenario
Server name : chnveltss04
Application name : Plan_UAT
Database name :
Variable value : LE_Wk1
Variable name : Fcst_Mth
Server name : chnveltss04
Application name : Plan_UAT
Database name :
Variable value : Jul
Variable name : Fcst_Wk
Server name : chnveltss04
Application name : Plan_UAT
Database name :
Variable value : Wk2
Variable name : NextScenario
Server name : chnveltss04
Application name : Plan_UAT
Database name :
Variable value : LE_Wk2
Appreciate your help.
Regards,
Ragav.
I need to access a text file using VB and match the line "Variable name : Fcst_Wk" and return the 4th line below it and assign it to a variable. i.e i need the line "Variable value : Wk2" and assign it to a variable. The content of the file is as below.
Variable name : CurrScenario
Server name : chnveltss04
Application name : Plan_UAT
Database name :
Variable value : LE_Wk1
Variable name : Fcst_Mth
Server name : chnveltss04
Application name : Plan_UAT
Database name :
Variable value : Jul
Variable name : Fcst_Wk
Server name : chnveltss04
Application name : Plan_UAT
Database name :
Variable value : Wk2
Variable name : NextScenario
Server name : chnveltss04
Application name : Plan_UAT
Database name :
Variable value : LE_Wk2
Appreciate your help.
Regards,
Ragav.
推荐答案
如果您的文本文件确实被cariage返回删除了,那么
If you textfile is really delimeted by a cariage return you can do
Dim Fourthline = (YourText.Split(CChar(Environment.NewLine)))(3)
这篇关于匹配一行并从中返回第4行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文