locked
I NEED HELP PLEASE RRS feed

  • Question

  • i am in my first term in college and have am assignment in intro to programming. the is language VB. Here is the problem.

       Ned's Health club wants an application that calculates and displays a member's monthly dues. Each member is charged a basic fee of $25; however, there are additional monthly charges for Golf, Racquetball, and tennis.the additional monthly charges are $5 for Racquetball, $10 for golf and $20 tennis. The interface should include 3 check boxes for the additional monthly charge information. Use a text box for the member's name and a label to display the monthly dues.

    I am trying to figure out how to do the check boxes the way there supposed to work the text book does not cover multiple  or adding values assigned to them. Could someone please help this assignment is due today.

    The only thing i have a problem with is the whole check box thing.

    Friday, March 11, 2011 4:31 PM

Answers

  • try this:

     

    Public Class Form1
    
      Dim basicFee As Integer = 25
      Dim monthlyDues As Integer
    
      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        monthlyDues = basicFee
        Label1.Text = monthlyDues.ToString("c2")
      End Sub
    
      Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
        monthlyDues += If(CheckBox2.Checked, 5, -5)
        Label1.Text = monthlyDues.ToString("c2")
      End Sub
    
      Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        monthlyDues += If(CheckBox1.Checked, 10, -10)
        Label1.Text = monthlyDues.ToString("c2")
      End Sub
    
      Private Sub CheckBox3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox3.CheckedChanged
        monthlyDues += If(CheckBox3.Checked, 20, -20)
        Label1.Text = monthlyDues.ToString("c2")
      End Sub
    
    End Class
    

    thanks for any help
    • Marked as answer by brad belville Friday, March 11, 2011 5:00 PM
    Friday, March 11, 2011 4:46 PM

All replies

  • essentially in the button click event, which is where I assume you are going to calculate your monthly total, you would use 3 If...Then blocks, one for each Checkbox.

    you would want to test If checkbox1 checked, then add $5 to the dues. Something like:

     

    If someCheckBox.Checked Then
    
     'code to add extra fee to dues
    
    End If

     

    Friday, March 11, 2011 4:40 PM
  • try this:

     

    Public Class Form1
    
      Dim basicFee As Integer = 25
      Dim monthlyDues As Integer
    
      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        monthlyDues = basicFee
        Label1.Text = monthlyDues.ToString("c2")
      End Sub
    
      Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
        monthlyDues += If(CheckBox2.Checked, 5, -5)
        Label1.Text = monthlyDues.ToString("c2")
      End Sub
    
      Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        monthlyDues += If(CheckBox1.Checked, 10, -10)
        Label1.Text = monthlyDues.ToString("c2")
      End Sub
    
      Private Sub CheckBox3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox3.CheckedChanged
        monthlyDues += If(CheckBox3.Checked, 20, -20)
        Label1.Text = monthlyDues.ToString("c2")
      End Sub
    
    End Class
    

    thanks for any help
    • Marked as answer by brad belville Friday, March 11, 2011 5:00 PM
    Friday, March 11, 2011 4:46 PM
  • Thank you this code works perfect all i had to do was change it all over to a click event. Thankyou sooooooooo much.
    Brad Belville
    Friday, March 11, 2011 6:31 PM
  • Hello Brad, I too am in VB Basics and have a similar project. Can you show me how you started this code?? also do you know how to declare a class-level variable to keep track of the additional charges. ??

     

    Thanks, your help will help me out alot for I am lost.

    Wednesday, October 19, 2011 7:40 PM