从记事本读取数据 [英] reading data from notepad
本文介绍了从记事本读取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我想从VB.NET中的文本文件读取数据.
文本文件包含如下数据:
Hi all,
I would like to read data from text file in VB.NET.
The text file contains data like:
DT 0600616222001 NOUF SALAH ABDULLATIF ALATEEQI 20110813 000010000 FR-0600-616222-GHARITY REF 338 0600051970001
我想从上面的行中读取字符串"0600051970001".
我的意思是该行的最后一条语句.
请为此提供示例代码.
I would like to read string "0600051970001" from the above line.
I mean the last statement of the line.
Please give me sample code for this.
推荐答案
line.SubString(line.LastIndexOf(" ") + 1).Trim
尝试以下代码.
Try as below code.
Dim oFile as System.IO.File
Dim oRead as System.IO.StreamReader
Dim fileText as String
Dim myText as String
oRead = oFile.OpenText("YourFilePath")
fileText = oRead.ReadToEnd()
myText = fileText.SubString(fileText.LastIndexOf(" ") + 1).Trim
这篇关于从记事本读取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文