Click here to Skip to main content
15,911,762 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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   

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.
Posted
Updated 18-Nov-11 23:41pm
v2

VB
line.SubString(line.LastIndexOf(" ") + 1).Trim
 
Share this answer
 
Comments
Abhinav S 19-Nov-11 4:55am    
My 5!
Try as below code.
VB
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900