I'm trying to calculate tip using radio buttons and use them to select the percentage but the variable "tip" doesn't transfer over to the next sub and lblTip.text keeps coming up as 0
Here's my code:
Public Class Form1
Dim tip As Double
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
Private Sub btnDisplay_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
Select Case True
Case rbtnTen.Checked
tip = 0.1
Case rbtnFifteen.Checked
tip = 0.15
Case rbtnTwenty.Checked
tip = 0.2
End Select
End Sub
Private Sub btnCalcTip_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCalcTip.Click
lblTip.Text = Val(txtBill.Text) * tip
End Sub
End Class
Select Case Trueis considered bad programming practise you could useIf Then ElseIf End Ifin this scenario, 2) You should switchOption Strict On- this would alert you to an error in the code you posted