Option Buttons and Instant Label Display

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MiziaQ
    New Member
    • Nov 2007
    • 63

    Option Buttons and Instant Label Display

    Hey, how can I display a price in a label INSTANTLY, each time an option button is pressed. Code example would be of great help :)

    Thanks in advance,

    MiziaQ
  • hariharanmca
    Top Contributor
    • Dec 2006
    • 1977

    #2
    explain your problem in detail.

    Comment

    • MiziaQ
      New Member
      • Nov 2007
      • 63

      #3
      I have many different frames with a couple of option buttons in each frame. Each option button selects an item worth a particular price. On the bottom of my form, I have a label named "total", which should accumulate the sum of the different prices selected through different option buttons. I would like to display the price in the "total" label when a particular option button is chosen, but without having to click on a button (i.e. the price and sum would be displayed in the label instantly, without having to press a button).

      Comment

      • hariharanmca
        Top Contributor
        • Dec 2006
        • 1977

        #4
        Can you post what you done so far?

        Comment

        • MiziaQ
          New Member
          • Nov 2007
          • 63

          #5
          No :( That's why I'm asking, I don't know how to do it ;)

          Comment

          • hariharanmca
            Top Contributor
            • Dec 2006
            • 1977

            #6
            In optionbutton click event, use

            [CODE=vb]lblTotal.Captio n = optButtonName.T ext[/CODE]

            Comment

            • Mohan Krishna
              New Member
              • Oct 2007
              • 115

              #7
              Originally posted by MiziaQ
              I have many different frames with a couple of option buttons in each frame. Each option button selects an item worth a particular price. On the bottom of my form, I have a label named "total", which should accumulate the sum of the different prices selected through different option buttons. I would like to display the price in the "total" label when a particular option button is chosen, but without having to click on a button (i.e. the price and sum would be displayed in the label instantly, without having to press a button).
              Hi
              If I got ur point and I am correct to ur problem, then take two frames each having two options groups [ Option1 (0) and Option1 (1) ; Option2 (2) and Option2 (3)], two labels - label1 and label2 to show the regarding price of the selected item. Then label3 to show their sum. As follows :
              Code:
              Private Sub Form_Load()
                  Option1(0).Value = False
                  Option1(1).Value = False
                  Option2(2).Value = False
                  Option2(3).Value = False
                  sum = 0
                  Label3.Caption = Format(sum, "#0.00")
              End Sub
              
              Private Sub Option1_Click(Index As Integer)
                  Select Case Index
                  Case 0
                      Label1.Caption = "10.00"
                  Case 1
                      Label1.Caption = "20.00"
                  End Select
                  sum = Val(Label1.Caption) + Val(Label2.Caption)
                  Label3.Caption = Format(sum, "#0.00")
              End Sub
              Private Sub Option2_Click(Index As Integer)
                  Select Case Index
                  Case 2
                      Label2.Caption = "30.00"
                  Case 3
                      Label2.Caption = "140.00"
                  End Select
                  sum = Val(Label1.Caption) + Val(Label2.Caption)
                  Label3.Caption = Format(sum, "#0.00")
              End Sub
              You can continue, if I got ur point, with the database and several options.

              ALL THE BEST!
              respond am I Correct...

              Comment

              • Killer42
                Recognized Expert Expert
                • Oct 2006
                • 8429

                #8
                What version of VB are you using? Control arrays aren't available in later versions.

                Comment

                Working...