Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15765

Reading a text file into array elements in Visual Basic

$
0
0
I have a question that may be simple to answer but I cannot find the answer anywhere on the Net.

I am programming in Visual Basic and would very much appreciate if you can help me with the following question:

I have a "space" delimited text file containing several line of data of the same format.

The file provides market data which I receive after a trading session is terminated such as Open Price, Close Price High and Low prices.

An example is gen below:

ID Date Open Close High Low

123 22.06.2020 12.25 14.25 12.85 11.90
111 21.06.2020 32.10 33.11 34.12 31.05
etc..

Each field in the line is separated by a single space only as shown above! I would like to know how to read the data in the text file into separate array element in my VB program for further processing.

I have the following declaration in my program:

Public Structure History_Data
Public req_id As Integer
Public Hst_Date As String
Public Hst_Open As Double
Public Hst_Close As Double
Public Hst_High As Double
Public Hst_Low As Double
End Structure

Public Hst_Array(100) As History_Data

My question is how can I read each piece of data in the text file into a separate array element (e.g. Open into Hst_Open, Close into Hst_Close, etc.) and repeat the process for each line read from the file until the end of the file is reached?

Your help is greatly appreciated!

Shariar

Viewing all articles
Browse latest Browse all 15765

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>