Results 1 to 2 of 2

Thread: Sigh, I'm stuck again T_T.

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2013
    Posts
    2

    Sigh, I'm stuck again T_T.

    Hi, I'm trying to make my programs show 10 in the label if I check 2 checkboxes, which plus 5 each. However, I only get 5 in the label despite the fact that I already checked 2 checkboxes + 5. Please help and thank you.
    Dim dblMon As Double
    Private Sub frmOrder_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    MessageBox.Show("Welcome to our restaurant.")

    End Sub

    Private Sub chkOp1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkOp1.Click
    If chkOp1.Checked = True Then
    lblMon.Text = dblMon + 5.0
    ElseIf chkOp1.Checked = False Then
    lblMon.Text = dblMon
    End If
    End Sub

    Private Sub chkOp2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkOp2.Click
    If chkOp2.Checked = True Then
    lblMon.Text = dblMon + 5.0
    ElseIf chkOp1.Checked = False Then
    lblMon.Text = dblMon
    End If
    End Sub
    End Class

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Sigh, I'm stuck again T_T.

    Nowhere do you ever check whether both boxes are checked and add 10. You display either (dblMon) or (dblMon + 5.0) but nowhere do you display (dblMon + 10.0). Start with dblMon, test the first box and add 5.0 if it's checked, test the second box and add 5.0 if it's checked and then display the result. Put that in a method and call it from both event handlers.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width