Question multiplying by two

indigo

Member
Joined
Mar 22, 2010
Messages
5
Programming Experience
Beginner
VB.NET:
Option Strict On
Public Class frmParkingTickets
    Private Sub frmParkingTickets_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    End Sub
    Private Sub pnlViolations_GotFocus(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pnlViolations.GotFocus

    End Sub
    'the btnDisplayFine event handler calculates the amount of the ticket based on user input.
    Private Sub btnDisplayFine_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplayFine.Click
        'Declaration Section
        Dim decTicketTotal As Decimal
        Dim decExpiredMeter As Decimal = 35D
        Dim decNoParkingZone As Decimal = 75D
        Dim decBlockingDriveway As Decimal = 150D
        Dim decIllegalHandicap As Decimal = 500D
        ' Determine Cost of Ticket
        If Me.radExpiredMeter.Checked Then
            decTicketTotal = decExpiredMeter
        ElseIf Me.radNoParkingZone.Checked Then
            decTicketTotal = decNoParkingZone
        ElseIf Me.radBlockingDriveway.Checked Then
            decTicketTotal = decBlockingDriveway
        ElseIf Me.radIllegalHandicap.Checked Then
            decTicketTotal = decIllegalHandicap
        End If
        'Calculate and display the cost of the ticket
        Me.lblTicketTotal.Text = decTicketTotal.ToString("C")

    End Sub


right now i have the following code. it is 4 radio buttons that if selected will display the price of a ticket.

there is a button called "repeat offender" that should take the price and double it. so me, being new to visual basic, were thinking of trying an if statement such as If it is selected decTicketTotal * 2

but this did not work. any help would be appreciated.. just trying to get the repeat offender selection working so when it calculates the price will double.
 
vs2jba.jpg


it's a selection the person can make.. if the selection is made the total will be doubled. so there is only one button and that is to calculate.
 
So it's not a button at all, despite your insistence to the contrary. From that image I would say that it's a RadioButton. Is that correct? If so then, as I said, a CheckBox would be more appropriate. Either way, you simply test its Checked property and double the value if it's True. It's done exactly the same as it would be if you were writing out a mathematical calculation with pen and paper.
 
VB.NET:
If yourRadioButton.Checked = True Then
     decTicketTotal *= 2
End If

You're already checking the .Checked Property for your other RadioButtons. Just check if this one is checked and multiply your total by 2.
 
Back
Top