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

Recommended Answers

All 7 Replies

Is there any one out there who can help?

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 :

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

try it and give a feedback

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?

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):

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

Or

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!

First off, you don't need to use the statement With Me because it's redundant.

agree with Oxiegen...

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. ;)

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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.