943,987 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Marked Solved
  • Views: 2815
  • VB.NET RSS
May 7th, 2008
0

display output prompted by radio button

Expand Post »
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
hermit08 is offline Offline
5 posts
since May 2008
May 7th, 2008
0

Re: display output prompted by radio button

Is there any one out there who can help?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
hermit08 is offline Offline
5 posts
since May 2008
May 7th, 2008
1

Re: display output prompted by radio button

Quote ...
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 :
vb.net Syntax (Toggle Plain Text)
  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.
Reputation Points: 1182
Solved Threads: 392
Posting Sensei
Jx_Man is offline Offline
3,145 posts
since Nov 2007
May 7th, 2008
0

Re: display output prompted by radio button

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?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
hermit08 is offline Offline
5 posts
since May 2008
May 7th, 2008
0

Re: display output prompted by radio button

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):
VB.NET Syntax (Toggle Plain Text)
  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
VB.NET Syntax (Toggle Plain Text)
  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.
Reputation Points: 87
Solved Threads: 128
Practically a Master Poster
Oxiegen is offline Offline
652 posts
since Jun 2006
May 7th, 2008
0

Re: display output prompted by radio button

Click to Expand / Collapse  Quote originally posted by Oxiegen ...
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.
Reputation Points: 1182
Solved Threads: 392
Posting Sensei
Jx_Man is offline Offline
3,145 posts
since Nov 2007
May 7th, 2008
0

Re: display output prompted by radio button

Quote ...
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.
Reputation Points: 10
Solved Threads: 8
Junior Poster
toko is offline Offline
104 posts
since Aug 2007
May 7th, 2008
0

Re: display output prompted by radio button

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!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
hermit08 is offline Offline
5 posts
since May 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: BobCat Motors Solution
Next Thread in VB.NET Forum Timeline: Bad Quality Printing - Badge Card Printer





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC