| | |
display output prompted by radio button
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: May 2008
Posts: 5
Reputation:
Solved Threads: 0
Hi there, i am a beginner so please don't laugh at how basic my question is. I don't understand why when i check the radio button the constant doesnt appear in the label..i'll put in the bit of code i am working on but if you need to see the whole thing let me know.
Thanks in advance.
Public Class Form1
'Declare the Constants
Const MAKEOVER_Decimal As Decimal = 125D
Const HAIR_STYLING_Decimal As Decimal = 60D
Const MANICURE_Decimal As Decimal = 35D
Const PERMANENT_MAKEUP_Decimal As Decimal = 200D
'Declare Variables for Summary information
Private TotalDecimal As Decimal
Private Sub CalculateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalculateButton.Click
'Calculate and display the amounts and add to totals
With Me
If makeoverRadioButton.Checked Then
.MakeoverLabel.Text = MAKEOVER_Decimal.ToString()
If HairStylingRadioButton.Checked Then
.hairStylingLabel.Text = HAIR_STYLING_Decimal.ToString()
If manicureRadioButton.Checked Then
.manicureLabel.Text = MANICURE_Decimal.ToString()
If permanentMakeupRadioButton.Text = PERMANENT_MAKEUP_Decimal.ToString() Then
End If
End If
End If
End If
End With
End Sub
Private Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.Click
Me.Close()
End Sub
End Class
Thanks in advance.
Public Class Form1
'Declare the Constants
Const MAKEOVER_Decimal As Decimal = 125D
Const HAIR_STYLING_Decimal As Decimal = 60D
Const MANICURE_Decimal As Decimal = 35D
Const PERMANENT_MAKEUP_Decimal As Decimal = 200D
'Declare Variables for Summary information
Private TotalDecimal As Decimal
Private Sub CalculateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalculateButton.Click
'Calculate and display the amounts and add to totals
With Me
If makeoverRadioButton.Checked Then
.MakeoverLabel.Text = MAKEOVER_Decimal.ToString()
If HairStylingRadioButton.Checked Then
.hairStylingLabel.Text = HAIR_STYLING_Decimal.ToString()
If manicureRadioButton.Checked Then
.manicureLabel.Text = MANICURE_Decimal.ToString()
If permanentMakeupRadioButton.Text = PERMANENT_MAKEUP_Decimal.ToString() Then
End If
End If
End If
End If
End With
End Sub
Private Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.Click
Me.Close()
End Sub
End Class
•
•
•
•
Private Sub CalculateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalculateButton.Click
'Calculate and display the amounts and add to totals
With Me
If makeoverRadioButton.Checked Then
.MakeoverLabel.Text = MAKEOVER_Decimal.ToString()
If HairStylingRadioButton.Checked Then
.hairStylingLabel.Text = HAIR_STYLING_Decimal.ToString()
If manicureRadioButton.Checked Then
.manicureLabel.Text = MANICURE_Decimal.ToString()
If permanentMakeupRadioButton.Text = PERMANENT_MAKEUP_Decimal.ToString() Then
End If
End If
End If
End If
End With
End Sub
1. you didn't used else so your if statement become a nested if.
2. you don't assign radio button as true when you checked them in if statement.
3. your last if statement is wrong (permanentMakeupRadioButton.Text = PERMANENT_MAKEUP_Decimal.ToString)
this following code is a right :
vb.net Syntax (Toggle Plain Text)
With Me If makeoverRadioButton.Checked = True Then .MakeoverLabel.Text = MAKEOVER_Decimal.ToString() Else If HairStylingRadioButton.Checked = True Then .hairStylingLabel.Text = HAIR_STYLING_Decimal.ToString() Else If manicureRadioButton.Checked = True Then .manicureLabel.Text = MANICURE_Decimal.ToString() Else If permanentMakeupRadioButton.Checked = True Then .permanentMakeupLabel.Text = PERMANENT_MAKEUP_Decimal.ToString() End If End If End If End If End With
Last edited by Jx_Man; May 7th, 2008 at 4:38 am.
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
So, Please do something before post your thread.
* PM Asking will be ignored *
•
•
Join Date: Jun 2006
Posts: 45
Reputation:
Solved Threads: 3
First off, you don't need to use the statement
Second, in an If statement there's only need for (in my oppinion) one Else.
As the If statement is for checking different values you should use:
This is what I would do (I agree about the last If statement being wrong):
Or
Good luck!
With Me because it's redundant.Second, in an If statement there's only need for (in my oppinion) one Else.
As the If statement is for checking different values you should use:
IF {something} Else If {something else} Else {totally different} End If This is what I would do (I agree about the last If statement being wrong):
VB.NET Syntax (Toggle Plain Text)
If makeoverRadioButton.Checked Then MakeoverLabel.Text = MAKEOVER_Decimal.ToString() Else If HairStylingRadioButton.Checked Then hairStylingLabel.Text = HAIR_STYLING_Decimal.ToString() Else If manicureRadioButton.Checked Then manicureLabel.Text = MANICURE_Decimal.ToString() Else permanentMakeupLabel.Text = PERMANENT_MAKEUP_Decimal.ToString() End If
VB.NET Syntax (Toggle Plain Text)
If makeoverRadioButton.Checked Then MakeoverLabel.Text = MAKEOVER_Decimal.ToString() End IF If HairStylingRadioButton.Checked Then hairStylingLabel.Text = HAIR_STYLING_Decimal.ToString() End IF If manicureRadioButton.Checked Then manicureLabel.Text = MANICURE_Decimal.ToString() End IF If permanentMakeupRadioButton.Checked = True Then permanentMakeupLabel.Text = PERMANENT_MAKEUP_Decimal.ToString() End If
Good luck!
Last edited by Oxiegen; May 7th, 2008 at 11:31 am.
Last edited by Jx_Man; May 7th, 2008 at 12:44 pm.
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
So, Please do something before post your thread.
* PM Asking will be ignored *
•
•
•
•
If makeoverRadioButton.Checked Then
.MakeoverLabel.Text = MAKEOVER_Decimal.ToString()
If HairStylingRadioButton.Checked Then
.hairStylingLabel.Text = HAIR_STYLING_Decimal.ToString()
If manicureRadioButton.Checked Then
.manicureLabel.Text = MANICURE_Decimal.ToString()
Just thought i would clear that up since no one mentioned it. Everything else was said by Jx_ Man & Oxiegen.
![]() |
Other Threads in the VB.NET Forum
- Previous Thread: BobCat Motors Solution
- Next Thread: Bad Quality Printing - Badge Card Printer
| Thread Tools | Search this Thread |
.net .net2008 30minutes 2005 2008 access account arithmetic array basic bing button buttons center check code combobox component connectionstring crystalreport data database databasesearch datagrid datagridview date design dissertation dissertations dropdownlist excel fade file-dialog filter folder ftp generatetags google gridview hardcopy images input insert intel internet mobile monitor ms net networking objects output panel passingparameters peertopeervideostreaming picturebox picturebox1 port position print printing problem problemwithinstallation project save searchbox searchvb.net select serial shutdown soap survey table tcp temperature text textbox timer timespan toolbox trim update updown user vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web winforms wpf year






