validation for the Calculate button
vb Code:
  1. Private Sub cmd_calc_Click()
  2. If IsNumeric(Trim(Me.txt_end_odom)) And IsNumeric(Trim(Me.txt_begin_odom)) Then
  3.     Dim sngMilesDriven As Single
  4.     Dim sngGallonsConsumed As Single
  5.    
  6.     sngMilesDriven = txt_end_odom.Text - txt_begin_odom.Text
  7.     txt_miles_driven.Text = sngMilesDriven
  8.    
  9.     sngGallonsConsumed = txt_total_cost.Text / txt_price_per_gal.Text
  10.     txt_gal_consumed.Text = Format(sngGallonsConsumed, "Fixed")
  11.    
  12.     txt_mpg.Text = Format(sngMilesDriven / sngGallonsConsumed, "Fixed")
  13.    
  14.     txt_gas_cost_mile.Text = Format(txt_total_cost.Text / sngMilesDriven, "Currency")
  15. Else
  16.     MsgBox "Please enter a valid odometer reading", vbInformation, App.Title
  17. End If
  18. End Sub