The program is an inventory control that is suppose maintain store merchandise details in random access files for 3 store locations each location saved to its own RAF. It also uses multiple forms for user to add merchandise, edit/view merchandise details and display an inventory report. Everything is working in the code above except for the SHOW Button click event. This event is suppose to list only the name of each available item for whichever location selected by user. when I click the show button nothing happens.(All of the code above is on the main form)
Also I cannot get it to allow user to view item details nor edit the details for those button clicks. Or display an inventory report that lists the name of items in stock, how many in stock and the total value of all inventory for the selected location. (All of this code is not included because its on other forms.)

Imports System.IO

Public Class frmMain

    Inherits System.Windows.Forms.Form

    Public frmView As New frmViewMerchandise() 'Call to view merchandise form
    Public frmEdit As New frmEditMerchandise() 'Call to edit merchandise form
    Public frmDisplay As New frmInventoryReport() 'Call to inventory report form
    Public frmSplash As New SplashScreen() 'Call to splash screen
    Public intCounter As Integer


    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'Load names of locations into list box

        Dim sr As StreamReader
        Dim fileName As String 'variable name to store locations

        Try 'error checking to see if file exists

            sr = File.OpenText("Locations.txt") 'Open file

            Do While sr.Peek <> -1 'Read through file until end

                fileName = sr.ReadLine 'Read in location names

                lstLocation.Items.Add(fileName) 'output location names to list box

            Loop

        Catch ex As IO.FileNotFoundException
            MessageBox.Show("The file does not exist, Please Try Again.")

        End Try

    End Sub

    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        'Exit out of program

        End

    End Sub

    Private Sub btnAddLocation_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddLocation.Click
        'Add new locations

        Dim fileName As String 'variable name to store locations

        Dim sw As StreamWriter = IO.File.AppendText("Locations.txt") 'create file

        SaveFileDialog1.ShowDialog() 'save file
        fileName = SaveFileDialog1.FileName
        sw.WriteLine(fileName) 'write locations to file

        Try 'error checking to see if file exists

            'Open file in random access mode
            FileOpen(1, SaveFileDialog1.FileName, OpenMode.Random, , , Len(jagManiaModule.myMerchandise))

        Catch ex As IO.FileNotFoundException
            MessageBox.Show("The file was not found, Please Try Again.")

        Catch ex As IOException
            MessageBox.Show("File Error")

            lstLocation.Items.Add(fileName) 'list locations in list box

            'Check to see if user wants to add merchandise
            While (MsgBox("Do you want to add merchandise?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes)

                allowAdd() 'Call to add procedure

            End While

            FileClose(1) 'close random access file

            sw.Close() 'close text file

        End Try

    End Sub

    Private Sub btnView_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnView.Click
        'Show view merchandise form

        frmView.ShowDialog()

    End Sub

    Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click
        'Show edit merchandise form

        frmEdit.ShowDialog()

        allowEdit() 'Call to allow edit of merchandise info

    End Sub


    Private Sub btnShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShow.Click
        'Display name of merchandise for selected location

        For i As Integer = 1 To jagManiaModule.intCounter

            FileGet(1, myMerchandise, i)

            lstMerchandise.Items.Add(myMerchandise.strName)

        Next

End Sub
        

    Private Sub btnDisplayReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplayReport.Click
        'Show inventory report form

        frmDisplay.ShowDialog()

    End Sub

    Private Sub btnOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpen.Click
        'Open selected file

        Dim fileName As String 'variable name for stored locations

        OpenFileDialog1.ShowDialog()
        fileName = OpenFileDialog1.FileName

        Try 'error checking to see if file exists


            'Open file in random access mode
            FileOpen(1, OpenFileDialog1.FileName, OpenMode.Random, , , Len(jagManiaModule.myMerchandise))

        Catch ex As IO.FileNotFoundException
            MessageBox.Show("The file was not found, Please Try Again")

            lstLocation.Items.Add(fileName)

            'check to see if user wants to add merchandise
            While (MsgBox("Do you want to add merchandise?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes)

                allowAdd() 'Call to allow add procedure

            End While

            FileClose(1) 'Close random access file

        End Try

    End Sub

End Class

Suggestion: Use BinaryReader and BinaryWriter.

Suggestion: Use BinaryReader and BinaryWriter.

I am not familiar with either of those. Please explain

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.