VB在文本文件中搜索 [英] VB searching in text file

查看:90
本文介绍了VB在文本文件中搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一堆需要整理的文本文件。

我想做的是从
$中选择三条连续的行b $ b每个文本文件并将其写在另一个文本文件中。

这三行中的每一行都是以字符开头的,例如IH。

在这三行之后还有更多的行重复

,这些行以相同的字符开头,但我不想要b $ b想要带它们。


谢谢

Al

解决方案

打开文件并使用split方法将文件内容拆分为

返回行(split(mycontents,vbcrlf))。现在检查

数组的第一个成员,确保它以IH开头。并采取

数组的下两个成员。现在将其写入新的文本流。


这是你的追求吗?
sp ** @ ahwayside.com


" AL" < ar*@coe.neu.edu>在消息中写道

news:13 **************************** @ phx.gbl ... < blockquote class =post_quotes>嗨
我有一堆文本文件需要组织。
我想做的是从每个文本文件中选择三条连续的行并写将它们放在另一个文本文件中。
这三行中的每一行都以IH等字符开头。
在这三行之后还有更多的行重复
以同样的角色开始,但我不想拿它们。

谢谢
Al



你好,


" AL" < ar*@coe.neu.edu> schrieb:

我有一堆需要组织的文本文件。
我想要做的是从每个文本文件中选择三条连续的行并写下来在另一个文本文件中。
这三行中的每一行都以IH等字符开头。
在这三行之后还有更多的行重复
具有相同的性格,但我不想接受它们。




您已经得到了问题的答案。请始终留在

原始帖子中。请随时回复以前的

帖子。


问候,

Herfried K. Wagner

-

MVP·VB Classic,VB.NET
http://www.mvps.org/dotnet


您好

我应该如何使用分割功能。

我应该写一下:Character = lines(Split(IH,

vbCrLf))

我没有找到任何帮助MSDN。

如果你详细解释,我很感激。

谢谢

-----原始信息--- -
打开文件并使用split方法将文件
内容拆分为line(split(mycontents,vbcrlf))。现在检查阵列的
第一个成员,确保它以IH开头。然后拿下下一个
thearray的两名成员。现在把它写成一个新的文本流。

这是你的追求?
sp**@ahwayside.com

AL < ar*@coe.neu.edu>在消息中写道
新闻:13 **************************** @ phx.gbl ...


我有一堆文本文件需要
组织。我想要做的是从每个文本文件中选择三个连续行
,并将它们写在另一个文本
文件中。这三行中的每一行都以诸如IH之类的字符开始。
在这三个
行之后还有更多行重复,这些行以相同的字符开头,但我不是
想要带它们。

谢谢
Al





Hi
I have a bunch of text files which need to be organized.
What I want to do is to select three continuous lines from
each text file and write them down in another text file.
Each of those three line is started with character such
as "IH".
There are also more lines repeated after these three lines
which are started with the same character, but I do not
want to take them.

Thanks
Al

解决方案

Open the file and use the split method to split the file contents at the
return lines (split(mycontents, vbcrlf)). Now check the first member of the
array to make sure it starts with "IH" and take the next two members of the
array. Now write this to a new textstream.

Is this what your after?
sp**@ahwayside.com

"AL" <ar*@coe.neu.edu> wrote in message
news:13****************************@phx.gbl...

Hi
I have a bunch of text files which need to be organized.
What I want to do is to select three continuous lines from
each text file and write them down in another text file.
Each of those three line is started with character such
as "IH".
There are also more lines repeated after these three lines
which are started with the same character, but I do not
want to take them.

Thanks
Al



Hello,

"AL" <ar*@coe.neu.edu> schrieb:

I have a bunch of text files which need to be organized.
What I want to do is to select three continuous lines from
each text file and write them down in another text file.
Each of those three line is started with character such
as "IH".
There are also more lines repeated after these three lines
which are started with the same character, but I do not
want to take them.



You already got an answer to your question. Please always stay in the
original thread. Feel free to reply further questions to your previous
thread.

Regards,
Herfried K. Wagner
--
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet


Hi
How should I use the split function.
Should I just write: Character = lines(Split("IH",
vbCrLf))
I did not find any help in MSDN.
I appreciate if you explain it in detail.
Thanks

-----Original Message-----
Open the file and use the split method to split the file contents at thereturn lines (split(mycontents, vbcrlf)). Now check the first member of thearray to make sure it starts with "IH" and take the next two members of thearray. Now write this to a new textstream.

Is this what your after?
sp**@ahwayside.com

"AL" <ar*@coe.neu.edu> wrote in message
news:13****************************@phx.gbl...

Hi
I have a bunch of text files which need to be organized. What I want to do is to select three continuous lines from each text file and write them down in another text file. Each of those three line is started with character such
as "IH".
There are also more lines repeated after these three lines which are started with the same character, but I do not
want to take them.

Thanks
Al


.



这篇关于VB在文本文件中搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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