Conference Registration System

my total won't show as anything but $0.00- getting lost

Page 1 of 1

6 Replies - 3626 Views - Last Post: 15 October 2013 - 05:42 AM Rate Topic: -----

#1 subhuman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 02-February 10

Conference Registration System

Posted 21 February 2010 - 01:27 PM

So I've seen this exact same program posted under other circumstances, but none of them seem to specifically touch on my particular issue. For the record, I should've just taken accounting, turns out this is hard. But I am determined to at least finish out my VB Intermediate class. So if anyone wants to take a gander at what I'm leaving out here, it would be appreciated. Here's my code (two forms):

Public Class Main
    Public dblTotalCost As Double

    Sub btnOptions_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOptions.Click

        Dim conferenceOptions As New frmConferenceOptions()

        'Display a form that allow the user to select Conference Options.
        frmConferenceOptions.ShowDialog()

        'show the total cost
        lblTotalCost.Text = dblTotalCost.ToString("c")
    End Sub

    Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
        'clear everything.
        lblTotalCost.Text = String.Empty
        dblTotalCost = 0
        txtName.Clear()
        txtAddress.Clear()
        txtCity.Clear()
        txtState.Clear()
        txtZip.Clear()
        txtEmail.Clear()
        txtPhone.Clear()
        txtCompany.Clear()
    End Sub

    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        'exit the application
        Me.Close()
    End Sub
End Class
-------------------------------------------------------------------------------------------------------------
Public Class frmConferenceOptions

    Function TotalCost(ByRef dblTotalCost)
        Dim dblRegistration As Double
        Dim dblDinnerandReg As Double
        Dim dblPreCon As Double

        'conference registration
        If chkRegistration.Checked = True Then
            dblRegistration = 895
        Else
            dblRegistration = 0
        End If

        'dinner and keynote speech
        If chkDinnerKeynote.Checked = True Then
            dblDinnerandReg = 30
        Else
            dblDinnerandReg = 0
        End If

        'optional preconference workshop
        If lstWorkshops.SelectedIndex = 0 Then
            dblPreCon = 295
        ElseIf lstWorkshops.SelectedIndex = 1 Then
            dblPreCon = 295
        ElseIf lstWorkshops.SelectedIndex = 2 Then
            dblPreCon = 395
        ElseIf lstWorkshops.SelectedIndex = 3 Then
            dblPreCon = 395
        ElseIf lstWorkshops.SelectedIndex = -1 Then
            dblPreCon = 0
        End If

        dblTotalCost = dblRegistration + dblDinnerandReg + dblPreCon
        Return dblTotalCost

    End Function

    Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
        'clear checkboxes and deselect items on the listbox.
        chkRegistration.Checked = False
        chkDinnerKeynote.Checked = False
        lstWorkshops.SelectedIndex = -1
    End Sub

    Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
        'close the form and return to "main"
        Me.Close()
    End Sub
End Class

This post has been edited by AdamSpeight2008: 21 February 2010 - 02:02 PM
Reason for edit:: Added Code Tags


Is This A Good Question/Topic? 0
  • +

Replies To: Conference Registration System

#2 fixo  Icon User is offline

  • D.I.C Regular

Reputation: 85
  • View blog
  • Posts: 335
  • Joined: 10-May 09

Re: Conference Registration System

Posted 21 February 2010 - 02:32 PM

View Postsubhuman, on 21 February 2010 - 12:27 PM, said:


First you need declare TotalCost function as Public
Then you could be to get data from child form easily:
    Sub btnOptions_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOptions.Click

        Dim conferenceOptions As New frmConferenceOptions()

        'Display a form that allow the user to select Conference Options. 
        frmConferenceOptions.ShowDialog()
        Dim cost As Double = frmConferenceOptions.TotalCost(dblTotalCost)
        'show the total cost 
        lblTotalCost.Text = dblTotalCost.ToString("c")
    End Sub



~'J'~
Was This Post Helpful? 2
  • +
  • -

#3 subhuman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 02-February 10

Re: Conference Registration System

Posted 21 February 2010 - 08:49 PM

View Postfixo, on 21 February 2010 - 01:32 PM, said:

View Postsubhuman, on 21 February 2010 - 12:27 PM, said:


First you need declare TotalCost function as Public
Then you could be to get data from child form easily:
    Sub btnOptions_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOptions.Click

        Dim conferenceOptions As New frmConferenceOptions()

        'Display a form that allow the user to select Conference Options. 
        frmConferenceOptions.ShowDialog()
        Dim cost As Double = frmConferenceOptions.TotalCost(dblTotalCost)
        'show the total cost 
        lblTotalCost.Text = dblTotalCost.ToString("c")
    End Sub



~'J'~



THANK YOU!!!! it's always the obvious i miss out on.
Was This Post Helpful? 0
  • +
  • -

#4 fixo  Icon User is offline

  • D.I.C Regular

Reputation: 85
  • View blog
  • Posts: 335
  • Joined: 10-May 09

Re: Conference Registration System

Posted 22 February 2010 - 01:14 AM

View Postsubhuman, on 21 February 2010 - 07:49 PM, said:

View Postfixo, on 21 February 2010 - 01:32 PM, said:

View Postsubhuman, on 21 February 2010 - 12:27 PM, said:


First you need declare TotalCost function as Public
Then you could be to get data from child form easily:
    Sub btnOptions_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOptions.Click

        Dim conferenceOptions As New frmConferenceOptions()

        'Display a form that allow the user to select Conference Options. 
        frmConferenceOptions.ShowDialog()
        Dim cost As Double = frmConferenceOptions.TotalCost(dblTotalCost)
        'show the total cost 
        lblTotalCost.Text = dblTotalCost.ToString("c")
    End Sub



~'J'~



THANK YOU!!!! it's always the obvious i miss out on.


Glad you got it to work

Cheers :)

~'J'~
Was This Post Helpful? 0
  • +
  • -

#5 lennie_k  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 14-October 13

Re: Conference Registration System

Posted 14 October 2013 - 09:51 PM

I realize that this is an old post, but this code is driving me crazy. I wasn't sure if I should start a new thread, but since this is the thread that led me here, and it is relevent to my assignment, I am posting here. This thread actually helped me a lot, I can now get my total to show up on the first form (I had to switch the function to Public).

My problem now is that I cannot figure out how to stop the calculations if chkConfReg is not checked. My assignment requirements specifically state that "The user cannot register for the optional events, however, without selecting the conference registration of $895".

I won't post my entire code (unless requested) because it is very similar to the code posted by subhuman. I will post my second form, which is the one I'm having issues with. I have tried changing the chkConfReg If statements in all sorts of ways, but I am having no luck.

Any help would be greatly appreciated. This assignment is due at 11:59 tonight... I was going to type tomorrow, but I see that it is almost 1 am.... time for bed. Thank you in advance!!!
Lennie


Public Class frmConferenceOptions

    Public Function TotalCost(ByRef decTotal) As Decimal
        'Declare variables
        Dim decConfReg As Decimal
        Dim decKeyFee As Decimal
        Dim decWkShp As Decimal

        'Confirm registration box selected
        If chkConfReg.Checked = False Then
            decConfReg = 0
            MessageBox.Show("Please confirm conference registration", "Error")
        Else
            decConfReg = 895
        End If

        'Confirm keynote dinner selected
        If chkKeyFee.Checked = True Then
            decKeyFee = 30
        Else
            decKeyFee = 0
        End If

        'Confirm workshops selected
        If lstWkshp.SelectedIndex = 1 Then
            decWkShp = 295
        ElseIf lstWkshp.SelectedIndex = 2 Then
            decWkShp = 295
        ElseIf lstWkshp.SelectedIndex = 3 Then
            decWkShp = 395
        ElseIf lstWkshp.SelectedIndex = 4 Then
            decWkShp = 395
        ElseIf lstWkshp.SelectedIndex = 0 Then
            decWkShp = 0
        End If
        
        'Calculations
        decTotal = decConfReg + decKeyFee + decWkShp

        'Output to form1
        Return decTotal

    End Function

    'Close form2 and return to form1
    Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
        Me.Close()
        frmCRS.Show()
    End Sub

    'Clear form
    Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
        chkConfReg.Checked = False
        chkKeyFee.Checked = False
        lstWkshp.SelectedIndex = 0

    End Sub

'Checkboxes
    Private Sub chkConfReg_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkConfReg.CheckedChanged

    End Sub

    Private Sub chkKeyFee_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkKeyFee.CheckedChanged

    End Sub

    Private Sub lstWkshp_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstWkshp.SelectedIndexChanged

    End Sub
End Class



Was This Post Helpful? 0
  • +
  • -

#6 astonecipher  Icon User is offline

  • Major DIC Head
  • member icon

Reputation: 571
  • View blog
  • Posts: 2,554
  • Joined: 03-December 12

Re: Conference Registration System

Posted 14 October 2013 - 10:55 PM

For future reference start a new thread for a new question.

On your problem.

Have the starting enabled property of the listbox set to false. Then, check the state of radiobutton conference if checked = true. Enable the listbox. Also your conference cost variable could be a constant unless you change the value later in the program.
Was This Post Helpful? 1
  • +
  • -

#7 lennie_k  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 14-October 13

Re: Conference Registration System

Posted 15 October 2013 - 05:42 AM

THANK YOU!!!

I initially had the ConfReg as a constant, but for some reason Visual Studio kept telling me it was wrong. I returned it to a constant and removed the duplicate part of the code and it works great.

Thank you again! And next time I will start a new post. :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1