Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Spliting Mainframe file line

Status
Not open for further replies.

manrique83

Programmer
Apr 26, 2005
36
US
I am fairly new to programming. Is there a way to delimit the following record by position, or how should I go. The mainframe file is being FTP'd to my machine, VB.net program reads it and for reporting purposes I need the 828, 804 field, can anyone help in how to put this into an array, structured or not.

000107561756A083C20 YAHOO ON AND TRUCKING****828 123 3252
000107561756A301A20 GOOGLE N ARCHITECTURE*** 804 456 544
 
I'm guessing the number of '*'s is not consistent?

-Rick

----------------------
[banghead]If you're about to post an ASP.Net question,
please don't do it in the VB.Net forum[banghead]

[monkey] I believe in killer coding ninja monkeys.[monkey]
 
If your * signs are inconsistent (as Rick asks) but the position of the 828, 804 are the same from the end of the string then you could just use Substring to get them. e.g.
Code:
        Dim strLine As String = "000107561756A083C20  YAHOO ON AND TRUCKING****828 123 3252"
        strLine = strLine.Substring(strLine.Length - 12, 3)

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
The lines in the file are a certain length, so I can save (strLine.length - (position back untill 804 starts), 3) as an array?

Thanks alot ca8msm
By the way, each record contains 4 stars, but they may or may not be in sequential order.
 
If it is always the first group of numbers after the "*" I would use LastIndexOf and grab the last part of the line...then use Split " " to get the number groups.

JMHO

:)
 
If the 828,804 field is always the same number of characters over you can use

strLine = "..."'the line read from the mainframe
'start pos is the number of characters from the left you
'want to start at. Length is the number of character you
'want to grab
MyValue = strline.substring(StartPos,Length)

Another option would be like Kevin mentioned with
strLine = "..."'the line read from the mainframe
myvalue = strLine.Substring(strLine.LastIndexOf("*")).Split(" ")(0)

That'll grab the first block of text after the last * until the first space.

-Rick

----------------------
[banghead]If you're about to post an ASP.Net question,
please don't do it in the VB.Net forum[banghead]

[monkey] I believe in killer coding ninja monkeys.[monkey]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top