By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,646 Members | 2,063 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,646 IT Pros & Developers. It's quick & easy.

Option Buttons and Instant Label Display

P: 63
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
Nov 29 '07 #1
Share this Question
Share on Google+
7 Replies


hariharanmca
100+
P: 1,977
explain your problem in detail.
Nov 29 '07 #2

P: 63
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).
Nov 29 '07 #3

hariharanmca
100+
P: 1,977
Can you post what you done so far?
Nov 29 '07 #4

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

hariharanmca
100+
P: 1,977
In optionbutton click event, use

Expand|Select|Wrap|Line Numbers
  1. lblTotal.Caption = optButtonName.Text
Nov 29 '07 #6

Mohan Krishna
100+
P: 115
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 :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.     Option1(0).Value = False
  3.     Option1(1).Value = False
  4.     Option2(2).Value = False
  5.     Option2(3).Value = False
  6.     sum = 0
  7.     Label3.Caption = Format(sum, "#0.00")
  8. End Sub
  9.  
  10. Private Sub Option1_Click(Index As Integer)
  11.     Select Case Index
  12.     Case 0
  13.         Label1.Caption = "10.00"
  14.     Case 1
  15.         Label1.Caption = "20.00"
  16.     End Select
  17.     sum = Val(Label1.Caption) + Val(Label2.Caption)
  18.     Label3.Caption = Format(sum, "#0.00")
  19. End Sub
  20. Private Sub Option2_Click(Index As Integer)
  21.     Select Case Index
  22.     Case 2
  23.         Label2.Caption = "30.00"
  24.     Case 3
  25.         Label2.Caption = "140.00"
  26.     End Select
  27.     sum = Val(Label1.Caption) + Val(Label2.Caption)
  28.     Label3.Caption = Format(sum, "#0.00")
  29. End Sub
  30.  
You can continue, if I got ur point, with the database and several options.

ALL THE BEST!
respond am I Correct...
Nov 29 '07 #7

Expert 5K+
P: 8,434
What version of VB are you using? Control arrays aren't available in later versions.
Nov 29 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.