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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to parse a text file into a grid or tab or form or ?

Status
Not open for further replies.

HolyRoller

Programmer
Aug 6, 2003
7
US
I'm attempting to create an HL7 (an EDI format) parser. The following is an example of the data:


MSH|^~\&|AMR18||SCH06||20040524140917||SIU^S12^SIU_S12|4561|P|2.3.1||
SCH||1275381|||||GAKL2||10|MIN|^^^20040524003500|SSMITH^SMITH^STEVEN
^^^^||||SSMITH^SMITH^STEVEN^^^^||||SSMITH^SMITH^STEVEN^^^^|||||SCHEDULED
PID|||00434028^^^KP1105^MR||JONES^JESSICA^^^^^PR||19840701|F|||17789 MONTEREY PINE DRIVE^^STRONGSVILLE^OH^44136^^RS||^PRN^PH^^^440^5726054|^WPN^PH^^^216^
4335252||||||||||||||||N
PV1|||^^^PRM||||||||||||||||1275381
RGS|1||RAD*
AIS|1||GAKL2|||||||SCHEDULED
AIG|1||RAD20|2^RESOURCE||||20040524003500|0|MIN|10|MIN


So, what I've been able to set up is a record-by-record read of the file (which contains the above data) and by using a loop until the text file is EOF, I create one tab for each record (labelled MSH, SCH, PID, etc...). What I want to do is take every field on each record and put it in its corresponding tab on the form.

I've tried to dynamically put a text field on the tabs, tried to think of using a grid, but I'm perplexed on how I might be able to accomplish what I'm looking to do.

Any help will be gratefully received!
 
Is it realy necesary to have a tab per record? If not you maybe could only show one record at a time adding next and previous buttons or something to navigate.
You could read all records in a array (or collection) to not have to access the file over and over?

regards
Johpje

 
I don't know that it's necessary for me to have all of those tabs, but my main problem at this point is to be able to parse the fields for any one particular record and put them on a tab as a text field, piece of a grid, anything. Can you help with that?

TIA! :)
 
Try splitting each record into an array
Dim MyArray() As String
'*

MyArray = Split(record, "|")
For i = 0 To UBound(MyArray)

'any code working with each field in the array
'including using the first field as the tab name

Next i
hope this helps!
 
search (advanced Help) for basGrabFile (try var spelling) it shows an easy way go grab a file and parse it according to delimiters. The demo which accompanies some some of the postings actually returns the parsed file as an array, albeit using a different character (conmma o space?) vs your "pipe" char, but that is a trivial substution.




MichaelRed
mlred@verizon.net

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top