Question Text file Reading and Storing values to Specific Structure

avijitjana77

New member
Joined
Apr 17, 2010
Messages
1
Programming Experience
Beginner
Dear All
I am trying to Read the text file line by line and also want to
store the data with specific structure for calculation.

Basically its a Coma(,) Delineated text string following a specific paten.

**********************************************************************************

HALGN,INTERCHANGE,INTERCHANGE
300,LB=MC00,TL=0.100000,CE=0.00,CT=0.00,ME
305,SC=0.000000,CF=0.000000
301,1,SX,X1=227031.459646,Y1=486428.725763,X2=227074.015638
305,Y2=486494.092347
301,2,LL,X1=226980.282807,Y1=486635.628160,RA=-92.500000
303,215.722705
999

**********************************************************************************
Concept Work flow with my understanding


1st it should match the Word "HALGN" then it will store the
INTERCHANGE & INTERCHANGE to a structure.

2nd it should Try the Word "300" and read MC00 ,0.1000, etc to a
Structure.

3rd "305" mean the continuation of previous (300 ) Data set line.

4th "301" is the starting of Element (line ) 1 with start (X1,Y1) and End
(X2,Y2) point

5rd "305" mean the continuation of previous (301 ) Data set line.

so on

"999" End of the "HALGN" option.

---------------------------------***********************----------------------------------------


I am new to VB.Net .Please ask me for any clarification.

Any Help / Guidance will be highly appreciable.


Regards
Avijit Jana
 
Dear All
I am trying to Read the text file line by line and also want to
store the data with specific structure for calculation.

Basically its a Coma(,) Delineated text string following a specific paten.

**********************************************************************************

HALGN,INTERCHANGE,INTERCHANGE
300,LB=MC00,TL=0.100000,CE=0.00,CT=0.00,ME
305,SC=0.000000,CF=0.000000
301,1,SX,X1=227031.459646,Y1=486428.725763,X2=227074.015638
305,Y2=486494.092347
301,2,LL,X1=226980.282807,Y1=486635.628160,RA=-92.500000
303,215.722705
999

**********************************************************************************
Concept Work flow with my understanding


1st it should match the Word "HALGN" then it will store the
INTERCHANGE & INTERCHANGE to a structure.

2nd it should Try the Word "300" and read MC00 ,0.1000, etc to a
Structure.

3rd "305" mean the continuation of previous (300 ) Data set line.

4th "301" is the starting of Element (line ) 1 with start (X1,Y1) and End
(X2,Y2) point

5rd "305" mean the continuation of previous (301 ) Data set line.

so on

"999" End of the "HALGN" option.

---------------------------------***********************----------------------------------------


I am new to VB.Net .Please ask me for any clarification.

Any Help / Guidance will be highly appreciable.


Regards
Avijit Jana

Welcome to the forum.

I would look to the trusty String class. It has an instance variable that looks something like this

VB.NET:
Dim FullPath As String = "c:\myfile.txt"

If System.IO.File.Exists(FullPath) Then

Dim TextFromFile As String

Dim objReader As StreamReader
objReader = New StreamReader(FullPath)
TextFromFile = objReader.ReadToEnd()
objReader.Close()

Dim FileValues() As String
FileValues = TextFromFile.Split(",")

'This will split the string and store each value in a string array using "," to 'know where to split.  Then you can iterate through your array and evaluate 'each value to determine what it is

For Each CurrentValue As String In FileValues

     'if CurrentValue has an ___ in it then do ____

Next

End If

You should also consider creating a structure or class to hold these values.

Please let me know if this helps.

Buddy B. (budbjames) on Twitter
 

Latest posts

Back
Top