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: hermit08 is an unknown quantity at this point 
Solved Threads: 0
hermit08 hermit08 is offline Offline
Newbie Poster

display output prompted by radio button

 
0
  #1
May 7th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 5
Reputation: hermit08 is an unknown quantity at this point 
Solved Threads: 0
hermit08 hermit08 is offline Offline
Newbie Poster

Re: display output prompted by radio button

 
0
  #2
May 7th, 2008
Is there any one out there who can help?
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: display output prompted by radio button

 
1
  #3
May 7th, 2008
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
why it can be :
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 :
  1. With Me
  2. If makeoverRadioButton.Checked = True Then
  3. .MakeoverLabel.Text = MAKEOVER_Decimal.ToString()
  4. Else
  5. If HairStylingRadioButton.Checked = True Then
  6. .hairStylingLabel.Text = HAIR_STYLING_Decimal.ToString()
  7. Else
  8. If manicureRadioButton.Checked = True Then
  9. .manicureLabel.Text = MANICURE_Decimal.ToString()
  10. Else
  11. If permanentMakeupRadioButton.Checked = True Then
  12. .permanentMakeupLabel.Text = PERMANENT_MAKEUP_Decimal.ToString()
  13. End If
  14. End If
  15. End If
  16. End If
  17. End With
try it and give a feedback
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 *
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 5
Reputation: hermit08 is an unknown quantity at this point 
Solved Threads: 0
hermit08 hermit08 is offline Offline
Newbie Poster

Re: display output prompted by radio button

 
0
  #4
May 7th, 2008
Thank you JX_Man, i made all the changes (some of them embarassingly obvious) but still the text doesnt show up in the labels. What am i missing?
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 62
Reputation: Oxiegen is an unknown quantity at this point 
Solved Threads: 3
Oxiegen Oxiegen is offline Offline
Junior Poster in Training

Re: display output prompted by radio button

 
0
  #5
May 7th, 2008
First off, you don't need to use the statement 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):
  1. If makeoverRadioButton.Checked Then
  2. MakeoverLabel.Text = MAKEOVER_Decimal.ToString()
  3. Else If HairStylingRadioButton.Checked Then
  4. hairStylingLabel.Text = HAIR_STYLING_Decimal.ToString()
  5. Else If manicureRadioButton.Checked Then
  6. manicureLabel.Text = MANICURE_Decimal.ToString()
  7. Else
  8. permanentMakeupLabel.Text = PERMANENT_MAKEUP_Decimal.ToString()
  9. End If
Or
  1. If makeoverRadioButton.Checked Then
  2. MakeoverLabel.Text = MAKEOVER_Decimal.ToString()
  3. End IF
  4. If HairStylingRadioButton.Checked Then
  5. hairStylingLabel.Text = HAIR_STYLING_Decimal.ToString()
  6. End IF
  7. If manicureRadioButton.Checked Then
  8. manicureLabel.Text = MANICURE_Decimal.ToString()
  9. End IF
  10. If permanentMakeupRadioButton.Checked = True Then
  11. permanentMakeupLabel.Text = PERMANENT_MAKEUP_Decimal.ToString()
  12. End If

Good luck!
Last edited by Oxiegen; May 7th, 2008 at 11:31 am.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: display output prompted by radio button

 
0
  #6
May 7th, 2008
Originally Posted by Oxiegen View Post
First off, you don't need to use the statement With Me because it's redundant.
agree with Oxiegen...
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 *
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 89
Reputation: toko is an unknown quantity at this point 
Solved Threads: 8
toko's Avatar
toko toko is offline Offline
Junior Poster in Training

Re: display output prompted by radio button

 
0
  #7
May 7th, 2008
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()
I don't see the point of the "." in front of every second line, it would be fine without it.

Just thought i would clear that up since no one mentioned it. Everything else was said by Jx_ Man & Oxiegen.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 5
Reputation: hermit08 is an unknown quantity at this point 
Solved Threads: 0
hermit08 hermit08 is offline Offline
Newbie Poster

Re: display output prompted by radio button

 
0
  #8
May 7th, 2008
thanks everyone...turns out i should have used checkboxes for multiple displays anyway...all the tips you all gave have been very helpful - thanks again!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the VB.NET Forum


Views: 1786 | Replies: 7
Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC