•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the VB.NET section within the Software Development category of DaniWeb, a massive community of 427,197 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,219 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our VB.NET advertiser: Programming Forums
Views: 577 | Replies: 1
![]() |
•
•
Join Date: Mar 2008
Posts: 8
Reputation:
Rep Power: 0
Solved Threads: 0
i have 3 check boxes then you check each indivual box the amount shows up in the appropiate label. but if you check more that one it will not add the values together does anyone have any idea how to the checkbox values to add together when more that one box is selected?/ here are the check box code:
vbnet Syntax (Toggle Plain Text)
Private Sub GolfCheckBox_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles GolfCheckBox.Click If Me.GolfCheckBox.Checked = True Then mintAdditional = 25 End If Me.AdditionalLabel.Text = Format(mintAdditional, "currency") End Sub Private Sub RacquetballCheckBox_click(ByVal sender As Object, ByVal e As System.EventArgs) Handles RacquetballCheckBox.Click If Me.RacquetballCheckBox.Checked = True Then mintAdditional = 20 End If Me.AdditionalLabel.Text = Format(mintAdditional, "currency") End Sub Private Sub TennisCheckBox_click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TennisCheckBox.Click If Me.TennisCheckBox.Checked = True Then mintAdditional = 30 End If Me.AdditionalLabel.Text = Format(mintAdditional, "currency") End Sub Private Sub CalcButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CalcButton.Click Dim intBasic As Integer Dim sngTotal As Single intBasic = Val(Me.BasicTextBox.Text) Select Case True Case Me.TennisCheckBox.Checked = True sngTotal = intBasic + mintAdditional Case Me.RacquetballCheckBox.Checked = True sngTotal = intBasic + mintAdditional Case Me.GolfCheckBox.Checked = True sngTotal = intBasic + mintAdditional End Select Me.TotalLabel.Text = Format(sngTotal, "currency") Me.AdditionalLabel.Text = Format(mintAdditional, "currency") End Sub
Last edited by WolfPack : Mar 22nd, 2008 at 11:53 am. Reason: Added code tags. Use them when you post code.
Mhm. Well I found it hard to follow your code and what exactly it does. But if I read correctly at the beginning you want to do the following:
I've little or no idea how to help you with your code though sorry as I find it hard to debug others code.
By the looks of things though you just keep on replacing the sngTotal instead of adding things on.
Just ask if you need any more help
EDIT: Oh yeh, all my checkbox names are default and the prices are just test numbers, so just change as you need
VBNET Syntax (Toggle Plain Text)
Public Class Learning2 Dim total As Double = 0 Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged If CheckBox1.Checked = True Then total = total + 30 ElseIf CheckBox1.Checked = False And total <> 0 Then total = total - 30 End If Label1.Text = FormatCurrency(total) End Sub Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged If CheckBox2.Checked = True Then total = total + 15 ElseIf CheckBox2.Checked = False And total <> 0 Then total = total - 15 End If Label1.Text = FormatCurrency(total) End Sub Private Sub CheckBox3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox3.CheckedChanged If CheckBox3.Checked = True Then total = total + 25 ElseIf CheckBox3.Checked = False And total <> 0 Then total = total - 25 End If Label1.Text = FormatCurrency(total) End Sub Private Sub Learning2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Label1.Text = FormatCurrency(total) End Sub End Class
I've little or no idea how to help you with your code though sorry as I find it hard to debug others code.
By the looks of things though you just keep on replacing the sngTotal instead of adding things on.
Just ask if you need any more help

EDIT: Oh yeh, all my checkbox names are default and the prices are just test numbers, so just change as you need
Last edited by BluePaper : Mar 22nd, 2008 at 11:20 am.
Stone In Focus - Caffeine Group - CoffeePHP - Open Notes - Onyx - Redpoint Network - Espresso
![]() |
•
•
•
•
•
•
•
•
DaniWeb VB.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Problem about my check box ! (PHP)
- I have problem with check box (PHP)
- Problem in Default Value of Check Box (JavaScript / DHTML / AJAX)
- internet explorer / virus problem here (Viruses, Spyware and other Nasties)
- Another problem with BRIDGE.DLL (Viruses, Spyware and other Nasties)
- xp - svchost using 100% - steps to diagnose problem? (Windows NT / 2000 / XP / 2003)
- Trojan Virus problem (Windows 9x / Me)
- internet explorer problem (Web Browsers)
- Small Downloading Problem (Web Browsers)
Other Threads in the VB.NET Forum
- Previous Thread: If Statements!....for a newbie :)
- Next Thread: I need Some help


Linear Mode