Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class frmMain
- 'Declare array of structure variables:
- Private itemList(4) As Product
- Structure Product
- Public strItem As String
- Public dblPrice As Double
- End Structure
- Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles Me.Load
- 'fill arrays with Item numbers and Prices
- Dim inFile As IO.StreamReader
- Dim intArray As Integer
- Dim intLength As Integer
- Dim strNum As String
- 'check to see if file exists
- If IO.File.Exists("ItemInfo.txt") Then
- 'open file for input
- inFile = IO.File.OpenText("ItemInfo.txt")
- 'process loop instructions until end of file
- Do Until inFile.Peek = -1
- 'read an item number
- strNum = inFile.ReadLine
- Integer.TryParse(strNum, intLength)
- If intLength = 5 Then
- itemList(intArray).strItem = strNum
- Else
- Double.TryParse(strNum, itemList(intArray).dblPrice)
- End If
- 'add item number to list box
- lstItems.Items.Add(itemList(intArray).strItem)
- intArray = intArray + 1
- Loop
- 'close the file
- inFile.Close()
- End If
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement