thnx
Public Class carRentalForm
' Dimension module - level variables and constants.
Private totalChargeDecimal, milesPriceDecimal, daysPriceDecimal As Decimal
Private milesInteger, zipCodeInteger, daysInteger As Integer
Const MILES_PRICE_Decimal As Decimal = 0.12D
Const DAYS_PRICE_Decimal As Decimal = 15D
Private Sub calculateButton_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles calculateButton.Click
' Calculate the miles and total charge.
Dim beginningInteger, endingInteger As Integer
With Me
Try
' Convert quantity to numeric variable.
beginningInteger = Integer.Parse(.beginningTextBox.Text)
endingInteger = Integer.Parse(.endingTextBox.Text)
Try
'Calculate number of miles and price.
milesInteger = endingInteger - beginningInteger
daysPriceDecimal = daysInteger * DAYS_PRICE_Decimal
milesPriceDecimal = MILES_PRICE_Decimal * milesInteger
totalChargeDecimal = milesPriceDecimal + daysPriceDecimal
' Format and display summary values.
.totalChargeTextBox.Text = totalChargeDecimal.ToString("C")
.milesTextBox.Text = milesInteger.ToString()
Catch beginningException As FormatException
' Handle a days driven exception.
MessageBox.Show("Beginning number of miles.", "Data Entry Error", _
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
With .beginningTextBox
.Focus()
.SelectAll()
End With
End Try
Try
Catch endingException As FormatException
' Handle a price exception.
MessageBox.Show("Ending number of miles.", "Data Entry Error", _
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
With .endingTextBox
.Focus()
.SelectAll()
End With
End Try
Try
Catch daysException As FormatException
' Handle a price exception.
MessageBox.Show("Days Rented.", "Data Entry Error", _
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
With .daysTextBox
.Focus()
.SelectAll()
End With
End Try
Catch anException As Exception
' Handle any other exception.
MessageBox.Show("Error: " & anException.Message)
End Try
End With
End Sub
Private Sub clearButton_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles clearButton.Click
' Clear previous amounts from the form.
With Me
.nameTextBox.Clear()
.addressTextBox.Clear()
.cityTextBox.Clear()
.stateTextBox.Clear()
.zipCodeTextBox.Clear()
.beginningTextBox.Clear()
.endingTextBox.Clear()
.milesTextBox.Clear()
.totalChargeTextBox.Clear()
With .daysTextBox
.Clear()
.Focus()
End With
End With
End Sub
Private Sub exitButton_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles exitButton.Click
'Exit the project.
Me.Close()
End Sub
End Class


