"Use radio buttons for the customer type and have them default to both being unselected when the program starts. Include a DO WHILE loop that checks to make sure one customer type is selected when clicking on the button and then automatically selects one or the other before ending the loop."
This is my code:
Public Class Form1 Private Sub btnCalculateBill_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCalculateBill.Click 'Declare Variables Dim bgnOdo As String = Me.txtBeginOdometer.Text Dim endOdo As String = Me.txtEndOdometer.Text Dim numDayRent As String = Me.txtNumDayRent.Text Dim numOfMiles As Decimal = 0 Const mileChrgB As Decimal = 0.12 '$0.12 for business Const mileChrgP As Decimal = 0.1 '$0.10 for personal Const rentalChrgB As Decimal = 15.0 '$15.00 for business Const rentalChrgP As Decimal = 12.5 '$12.50 for personal Dim totMileChrg As Decimal = 0 Dim totRentalChrg As Decimal = 0 Dim totDue As Decimal = 0 numOfMiles = endOdo - bgnOdo Do While Me.radPersonal.Checked = True Me.radBusiness.Checked = True Me.radPersonal.Checked = False Loop If Me.radBusiness.Checked Then 'Business Customer totMileChrg = mileChrgB * numOfMiles totRentalChrg = numDayRent * rentalChrgB totDue = totMileChrg + totRentalChrg End If If Me.radPersonal.Checked Then 'Personal Customer totMileChrg = mileChrgP * numOfMiles totRentalChrg = numDayRent * rentalChrgP totDue = totMileChrg + totRentalChrg End If Me.lblAmtOfMiles.Text = Format(numOfMiles, "General Number") Me.lblAmtOfMileChrg.Text = Format(totMileChrg, "Currency") Me.lblAmtDayUseChrg.Text = Format(totRentalChrg, "Currency") Me.lblTotDueDisplay.Text = Format(totDue, "Currency") End Sub
I have to radio buttons, one for Personal customers and one for Business Customers, each having there own price amount. When I run my program with the Do While Loop I have now, it lets me pick between personal or business, but when I click "Calculate Customer Bill" it automatically picks Business every time. I don't understand how to make the loop do as the instructions request "then automatically selects one or the other before ending the loop". Any advice or a better explanation on How a DO While Loop works would be appreciated.