radius = Val(Me.txtRadius.Text)
If radius < 0 Then
Me.lblArea.Text = "Negative radii are illegal."
End If
area = PI * (radius ^ 2)
Me.lblArea.Text = area 'Shows answer of area of circle
This should have resulted in no answer displaying if the radius entered was negative. However, an answer still showed up when I pressed Debug, so I went back and rearranged things:
radius = Val(Me.txtRadius.Text)
area = PI * (radius ^ 2)
Me.lblArea.Text = area 'Shows answer of area of circle
If radius < 0 Then
Me.lblArea.Text = "Negative radii are illegal."
End If
No comments:
Post a Comment