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.
Printable View
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.
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
Thanks a lot.
If I do not want write code in option button and use If statement,what can I do?
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
Can you help me with the code I attach.
The pizza Size does bot show,I do not know why.
Your zip file contains a .vbp (project file) and a .vbw (workspace file) but no form. :confused:
Why not just make it easier, and post the code you have that isn't working.
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
What isn't working?
The whole thing?
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?
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.
Thanks a lot...I will check it.