Close
Showing results 1 to 2 of 2

Hybrid View

  1. #1

    Default VB. net Coding help

    Since this is an off-topic thread and there seems to be a good amount of programmers here I thought id ask for a bit of assistance. Im trying to code 3 check boxes so when they are checked they will add x amount to an additionalCharges variable and then show the addition in a label. Then if they are unchecked they will subtract the addition canceling it out.

    I tried and if then else statement that looked like this

    If me.xgolfcheckbox.checked then
    additionalCharges = additionalCharges + 25
    else additionalCharges = additionalCharges -25
    End If

    What am I doing wrong. Not really looking for the right coding just and idea to point me in the right direction.
    "Come back with your shield. Or on it"
    The Fallen Angels

  2. #2

    Default

    It's been awhile since I've worked with VB, but if you're trying to adjust the value like that immediately when a box is checked/unchecked, you need to call the checkbox's CheckChanged event:
    (note, the syntax may be a little off.. it's been years since I've touched VB, so this is coming off the top of my head)
    Code:
    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
    If (CheckBox1.Checked = True) Then
    additionalCharges = additionalCharges + 25
    Else
    additionalCharges = additionalCharges - 25
    End If
    End Sub
    Edit:
    Generally I would have all the entry fields call an Update function that I write, then do all my work in the Update function to check all checkboxes/optionbuttons/values to calculate results. That way, you just have to call this Update function in the CheckChanged-type event for all objects that can be changed.
    Ex-WoW 5-boxer.
    Currently playing:
    Akama [Empire of Orlando]
    Zandantilus - 85 Shaman, Teebow - 85 Paladin, Kodex - 85 Rogue.

    Definitely going to 4-box Diablo 3 after testing the beta for how well this would work.

Similar Threads

  1. Game Design and Coding
    By Tamu in forum Off-Topic
    Replies: 16
    Last Post: 01-27-2009, 12:41 PM
  2. Please Help with coding for Focusless Setup
    By knopstr in forum General WoW Discussion
    Replies: 8
    Last Post: 10-03-2008, 03:39 PM

Posting Rules

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