|
-
Oct 10th, 2002, 02:04 PM
#1
Thread Starter
Member
OptionButton question
3 option buttons,
a=10
b=11
c=12
If I select a,
the numbers (10) will show in a label.
if b button,show "11"
if c ,show "12"
How can I do that?Thanks.
-
Oct 10th, 2002, 02:07 PM
#2
VB Code:
Private Sub opta_Click()
Label1.Caption = "10"
End Sub
Private Sub optb_Click()
Label1.Caption = "11"
End Sub
Private Sub optc_Click()
Label1.Caption = "12"
End Sub
-
Oct 10th, 2002, 02:09 PM
#3
Thread Starter
Member
Thanks a lot.
If I do not want write code in option button and use If statement,what can I do?
-
Oct 10th, 2002, 02:10 PM
#4
VB Code:
Private Sub Command1_Click()
If opta.Value = True Then
Label1.Caption = "10"
ElseIf optb.Value = True Then
Label1.Caption = "11"
Else
Label1.Caption = "12"
End If
End Sub
-
Oct 10th, 2002, 02:20 PM
#5
Thread Starter
Member
Can you help me with the code I attach.
The pizza Size does bot show,I do not know why.
Last edited by shiyu; Oct 10th, 2002 at 02:30 PM.
-
Oct 10th, 2002, 02:23 PM
#6
Your zip file contains a .vbp (project file) and a .vbw (workspace file) but no form.
Why not just make it easier, and post the code you have that isn't working.
-
Oct 10th, 2002, 02:24 PM
#7
Thread Starter
Member
ok
Code:
Option Explicit
Const msngSmall As Single = 10.25
Const msngMedium As Single = 15.75
Const msngLarge As Single = 19.95
Const msngTsmall As Single = 1.25
Const msngTmedium As Single = 1.45
Const msngTlarge As Single = 1.75
Dim mcurSmall As Currency
Dim mcurMedium As Currency
Dim mcurLarge As Currency
Dim mstrSize As String
Dim mcurBasic As Currency
Dim mcurTopping As Currency
Dim intToppingcount As Integer
Dim curPizzanumber As Currency
Dim intPizza As Integer
Dim mcurTotal As Currency
Private Sub chkShowdate_Click()
If chkShowdate.Value = 1 Then
lblDate.Caption = Date
Else
lblDate.Caption = ""
End If
End Sub
Private Sub cmdClear_Click()
'Clear all
optSmall.Value = False
optMedium.Value = False
optLarge.Value = False
chkMushroom.Value = 0
chkTomato.Value = 0
chkPepperoni.Value = 0
chkPepper.Value = 0
chkOnion.Value = 0
chkHam.Value = 0
txtPizzanumber.Text = ""
lblShowPizza.Caption = ""
lblShowtopping.Caption = ""
lblShowtotal.Caption = ""
chkShowdate.Value = 0
End Sub
Private Sub cmdDisplay_Click()
'display topping number
'Select Pizza Size
If optSmall.Value = True Then
mcurBasic = msngSmall
mstrSize = "Small"
mcurTopping = msngTsmall
lblShowPizza.Caption = "Small"
ElseIf optMedium.Value = True Then
mcurBasic = msngMedium
mstrSize = "Medium"
mcurTopping = msngTmedium
Else
optLarge.Value = True
mcurBasic = msngLarge
mstrSize = "Large"
mcurTopping = msngTlarge
End If
If chkOnion.Value = 1 Then
intToppingcount = intToppingcount + 0
End If
If chkHam.Value = 1 Then
intToppingcount = intToppingcount + 1
End If
If chkOnion.Value = 1 Then
intToppingcount = intToppingcount + 1
End If
If chkPepper.Value = 1 Then
intToppingcount = intToppingcount + 1
End If
If chkPepperoni.Value = 1 Then
intToppingcount = intToppingcount + 1
End If
If chkTomato.Value = 1 Then
intToppingcount = intToppingcount + 1
End If
If chkMushroom.Value = 1 Then
intToppingcount = intToppingcount + 1
End If
'Show topping number
lblShowtopping.Caption = Val(intToppingcount)
'Show Pizza Size Ordered
lblShowPizza.Caption = Val(mstrSize)
'Show Unit Cost
lblUnit.Caption = FormatCurrency(mcurBasic)
'get the price
intPizza = Val(txtPizzanumber.Text)
lblTotal.Caption = FormatCurrency(mcurTotal)
mcurTotal = mcurBasic * intPizza + intToppingcount * mcurTopping
End Sub
Private Sub cmdExit_Click()
'exit the program
End Sub
Private Sub Form_Load()
'when form load
optSmall.Value = False
optMedium.Value = False
optLarge.Value = False
End Sub
-
Oct 10th, 2002, 02:26 PM
#8
What isn't working?
The whole thing?
-
Oct 10th, 2002, 02:27 PM
#9
Thread Starter
Member
no,
when I click the display button,"lblShowPizza" shows me"0".
It should be show me Pizza Size"Small" "Medium" and "Large"
VB Code:
'Select Pizza Size
If optSmall.Value = True Then
mcurBasic = msngSmall
mstrSize = "Small"
mcurTopping = msngTsmall
lblShowPizza.Caption = "Small"
ElseIf optMedium.Value = True Then
mcurBasic = msngMedium
mstrSize = "Medium"
mcurTopping = msngTmedium
Else
optLarge.Value = True
mcurBasic = msngLarge
mstrSize = "Large"
mcurTopping = msngTlarge
End If
is this code right?
-
Oct 10th, 2002, 02:33 PM
#10
It looks right.
Put a "Stop" right before this code executes, and, using F8, walk through the code. Move your mouse over the variables to see what they actually contain.
-
Oct 10th, 2002, 02:35 PM
#11
Thread Starter
Member
Thanks a lot...I will check it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|