none
Can someone help me with a Conference Reg System PLEASE RRS feed

  • Question

  • I have been looking all around and coding for a couple days now and I am stuck. Can someone help me out. 

    I do not know how to get the lstSelectOne box to work and go back to the 1st form without it crashing

    Here is the instructions 

    https://imgur.com/a/rpxNj

    Thank you...

    Here is my code for frm1
    
    -------------------------------------
    
    Public Class frmConfrence
        Public dblTotalCost As Double
    
        Private Sub lblCompany_Click(sender As Object, e As EventArgs) Handles lblCompany.Click
    
        End Sub
    
        Private Sub lblState_Click(sender As Object, e As EventArgs) Handles lblState.Click
    
        End Sub
    
        Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
            Me.Close()
    
        End Sub
    
        Private Sub btnOptions_Click(sender As Object, e As EventArgs) Handles btnOptions.Click
    
            'Dims ConfrenceOptions as variable
            Dim ConfrenceOptions As New frmOptions
            'Displays options form
            frmOptions.ShowDialog()
            Dim cost As Double =
                frmOptions.TotalCost(dblTotalCost)
            'Show total cost
            lblTotal.Text = txtTotal.ToString("c")
    
        End Sub
    
        Private Sub btnReset_Click(sender As Object, e As EventArgs) Handles btnReset.Click
    
            'Clears all textboxes 
            lblTotal.Text = String.Empty
            txtTotal.Clear()
            txtName.Clear()
            txtAddresss.Clear()
            txtCity.Clear()
            txtState.Clear()
            txtZip.Clear()
            txtEmail.Clear()
            txtPhone.Clear()
            txtCompany.Clear()
    
        End Sub
    End Class
    ------------------------------
    
    Here is my code for frm2
    
    ------------------------------
    
    Public Class frmOptions
        Private Sub btnClose_Click(sender As Object, e As EventArgs) Handles btnClose.Click
            'Closes the form 
            Me.Close()
            frmConfrence.Show()
    
        End Sub
        'Creates a function for the total
        Public Function TotalCost(ByRef txtTotal)
            lstSelectOne.Width = 200
            Dim Wshop As Workshop
            Wshop = New Workshop("Introduction to E-commerce", 295)
            lstSelectOne.Items.Add(Wshop)
            Wshop = New Workshop("The Future of the web", 335)
            lstSelectOne.Items.Add(Wshop)
            Wshop = New Workshop("Advance Visual Basic", 395)
            lstSelectOne.Items.Add(Wshop)
            Wshop = New Workshop("Network Security", 435)
            lstSelectOne.Items.Add(Wshop)
    
            lstSelectOne.Width = 200
    
            'Dims the textboxes
            Dim dblRegistration As Double
            Dim dblOpen As Double
            Dim dblPreconfrence As Double
    
            'Confrence registration
            If chkConfrenceReg.Checked =
                    True Then
                dblRegistration = 895
            Else
                dblRegistration = 0
            End If
    
            'Dinner and speech
            If chkOpen.Checked =
                    True Then
                dblOpen = 30
            Else
                dblOpen = 0
            End If
    
            'Optional preconfrence workshop
            If lstSelectOne.SelectedIndex = 0 Then
                dblPreconfrence = 295
            ElseIf lstSelectOne.SelectedIndex = 1 Then
                dblPreconfrence = 295
            ElseIf lstSelectOne.SelectedIndex = 2 Then
                dblPreconfrence = 395
            ElseIf lstSelectOne.SelectedIndex = 3 Then
                dblPreconfrence = 395
            ElseIf lstSelectOne.SelectedIndex = -1 Then
                dblPreconfrence = 0
            End If
    
            Dim dblTotalCost As Object = txtTotal
            'Adds cost and displays in total
            dblTotalCost = dblRegistration + dblOpen + dblPreconfrence
            Return dblTotalCost
    
        End Function
    
        Private Sub btnReset_Click(sender As Object, e As EventArgs) Handles btnReset.Click
            'Clears checkboxes and deselects the listbox
            chkConfrenceReg.Checked = False
            chkOpen.Checked = False
            lstSelectOne.SelectedIndex = -1
        End Sub
    
        Private Sub lstSelectOne_SelectedIndexChanged(sender As Object, e As EventArgs) Handles lstSelectOne.SelectedIndexChanged
    
        End Sub
    End Class
    ---------------------



    • Edited by w1shin Tuesday, September 12, 2017 5:28 PM
    Tuesday, September 12, 2017 5:12 PM

All replies

  • Before getting into your question please edit your question, place all code into code sections via.

    Next indicate one problem you are stuck on rather than simply presenting code, especially when it's an assignment so you can learn from it.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Tuesday, September 12, 2017 5:18 PM
    Moderator
  • Hello,

    The first thing is my replies very well may be spread out as it's a busy day at work so bear with me.

    First off the following line uses the default instance of the form.

    frmOptions.ShowDialog()

    You should use the following in a single method such as a button click event

    Dim f As New frmOptions

    Use an "if" statement to determine if the response was yes or no. If yes you can access public assessors such as controls and variables from the variable "f" e.g. f.lstSelectOne.Text for instance and remember it to a variable (I'm currently in C# so I can get to vb.net now to do a better example).


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Tuesday, September 12, 2017 7:02 PM
    Moderator
  • I do not know how to get the lstSelectOne box to work and go back to the 1st form without it crashing

    If you show the form as a dialog, then there is no need to 'go back' to the first form. The form that opened the dialog is still there and can be accessed when the dialog is closed.  Remove the code you are using to show frmConference when the options form is closed.

    Tuesday, September 12, 2017 10:00 PM