Hi there,
I have been having some issues with an application for the past few days. I am writing code for an application that uses multiple forms. The main form has a menu that calls procedures to display a form with a list box containing print books, and an another with a list box containing audio books. For the application, I have a module containing constants declared for the prices of the books, the sales tax, and the shipping charge. I also have variables in order to store the selected book item, the sub total price, the tax charge, the total shipping charge, and the total cost. When a book on either form is selected, the book appears on the list box on the main form, and the sub total price, tax charge, total shipping charge, and the total cost are displayed in labels on the main form. All these values, are accumulated as each book is added, or even removed from the main form list box, or even using the print book and audio book forms.
My main issue, however, is setting the module I have created as the start up object. In order to achieve this, I used the following method:
I selected a form on the Solution Explorer, then I clicked Project. On the Project menu I clicked Properties. Under Application, I removed the check mark on the Enable application framework option. Then I clicked on the drop-down menu for Startup object. However, I was unable to find the name of my module which is titled modStandard. I only found names for: Sub Main, frmMain, frmPrint, frmAudio. Can someone please help with this problecem?
My second question is a bit more trivial, but I would like to resolve it. On either of the print or audio form, I am trying to write code for error checking. For example, on the print form, there is a list of print books. In order to add a book to the shopping cart list box on the main form, it is necessary to select the print book in the print book list box, and then click on the "Add Book To Cart" button. I have been trying to write error checking for these two events but my main issue is related to the "Close" button. Also, when the "Close" button on the form is selected, the selection is canceled, and the name of the book is removed from the shopping cart list box on the main form.
I have managed to get error-checking to work for the first event. When no item is selected on either the print or audio form, and the "Close" button is selected on either the print or audio form, a message box appears: "Select an item". For the second event, after an item has been selected on either the print and audio form, and the "Close" button is selected, a message box appears: "Add an item to the shopping cart". Also, after an item has been selected, and the "Add Book To Cart" button has been clicked, the name of the print or audio book item appears on the shopping cart list box on the main form, with its associated price, charges, and total cost. However, when the selected item is selected again, and the "Close" button has been clicked in order to remove the item from the shopping cart list box on the main form, I still get the message box "Add an item to the shopping cart", the item is not removed, and either of the audio or print form closes.
Here is sample code, from the audio form.
I have been having some issues with an application for the past few days. I am writing code for an application that uses multiple forms. The main form has a menu that calls procedures to display a form with a list box containing print books, and an another with a list box containing audio books. For the application, I have a module containing constants declared for the prices of the books, the sales tax, and the shipping charge. I also have variables in order to store the selected book item, the sub total price, the tax charge, the total shipping charge, and the total cost. When a book on either form is selected, the book appears on the list box on the main form, and the sub total price, tax charge, total shipping charge, and the total cost are displayed in labels on the main form. All these values, are accumulated as each book is added, or even removed from the main form list box, or even using the print book and audio book forms.
My main issue, however, is setting the module I have created as the start up object. In order to achieve this, I used the following method:
I selected a form on the Solution Explorer, then I clicked Project. On the Project menu I clicked Properties. Under Application, I removed the check mark on the Enable application framework option. Then I clicked on the drop-down menu for Startup object. However, I was unable to find the name of my module which is titled modStandard. I only found names for: Sub Main, frmMain, frmPrint, frmAudio. Can someone please help with this problecem?
My second question is a bit more trivial, but I would like to resolve it. On either of the print or audio form, I am trying to write code for error checking. For example, on the print form, there is a list of print books. In order to add a book to the shopping cart list box on the main form, it is necessary to select the print book in the print book list box, and then click on the "Add Book To Cart" button. I have been trying to write error checking for these two events but my main issue is related to the "Close" button. Also, when the "Close" button on the form is selected, the selection is canceled, and the name of the book is removed from the shopping cart list box on the main form.
I have managed to get error-checking to work for the first event. When no item is selected on either the print or audio form, and the "Close" button is selected on either the print or audio form, a message box appears: "Select an item". For the second event, after an item has been selected on either the print and audio form, and the "Close" button is selected, a message box appears: "Add an item to the shopping cart". Also, after an item has been selected, and the "Add Book To Cart" button has been clicked, the name of the print or audio book item appears on the shopping cart list box on the main form, with its associated price, charges, and total cost. However, when the selected item is selected again, and the "Close" button has been clicked in order to remove the item from the shopping cart list box on the main form, I still get the message box "Add an item to the shopping cart", the item is not removed, and either of the audio or print form closes.
Here is sample code, from the audio form.
Code:
Private Sub btnCloseAudio_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCloseAudio.Click
If lstSelectBookAudio.SelectedIndex = -1 Then
'No item is selected
MessageBox.Show("Select an item.")
ElseIf frmMain.lstProductsSelected.SelectedIndex = -1 Then
'No item is added to the shopping cart
MessageBox.Show("Add an item to the shopping cart")
ElseIf frmMain.lstProductsSelected.SelectedItem.ToString() <> String.Empty Then
g_strShoppingItem = lstSelectBookAudio.SelectedItem.ToString()
frmMain.lstProductsSelected.Items.Remove(g_strShoppingItem)[/SIZE]
End Sub