Option Strict On
Public Class frmBookPublishing
' Class Level Private Variables
Private Shared _intSizeOfArray As Integer = 16
Private Shared _strWarehouseItem(_intSizeOfArray) As String
Private _decBookPrice(_intSizeOfArray) As Decimal
Private _intBooksOnHand(_intSizeOfArray) As Integer
Private _intBooksOrdered(_intSizeOfArray) As Integer
Private Sub frmBookPublishing_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' The frmBookPublishing load event reads the warehouse text file and fills the ListBox object
' with the warehouse items.
' Initialize an instance of the Streamreader object and declare variables.
Dim objReader As IO.StreamReader
Dim strLocationAndNameofFile As String = "C:\Users\Stacey\Documents\Visual Studio 2008\Projects\FlicksBookPublishing\FlicksBookPubli shing\File\warehouse.txt"
Dim intCount As Integer = 0
Dim strFileError As String = "The file is not available. Restart when the file is available."
' Verify the file exists
If IO.File.Exists(strLocationAndNameofFile) Then
objReader = IO.File.OpenText(strLocationAndNameofFile)
'Read the file line by line until the file is completed
Do While objReader.Peek <> -1
_strWarehouseItem(intCount) = objReader.ReadLine()
_decBookPrice(intCount) = Convert.ToDecimal(objReader.ReadLine())
_intBooksOnHand(intCount) = Convert.ToInt32(objReader.ReadLine())
intCount += 1
_intBooksOrdered(intCount) = Convert.ToInt32(objReader.ReadLine())
intCount += 1
Loop
objReader.Close()
' Display the Names of the Books
For intFill = 0 To (_strWarehouseItem.Length - 1)
Me.lstBookTitles.Items.Add(_strWarehouseItem(intFi ll))
Next
Else
MsgBox(strFileError, , "Error")
Me.Close()
End If
End Sub