validation for the Calculate buttonvb Code:
Private Sub cmd_calc_Click() If IsNumeric(Trim(Me.txt_end_odom)) And IsNumeric(Trim(Me.txt_begin_odom)) Then Dim sngMilesDriven As Single Dim sngGallonsConsumed As Single sngMilesDriven = txt_end_odom.Text - txt_begin_odom.Text txt_miles_driven.Text = sngMilesDriven sngGallonsConsumed = txt_total_cost.Text / txt_price_per_gal.Text txt_gal_consumed.Text = Format(sngGallonsConsumed, "Fixed") txt_mpg.Text = Format(sngMilesDriven / sngGallonsConsumed, "Fixed") txt_gas_cost_mile.Text = Format(txt_total_cost.Text / sngMilesDriven, "Currency") Else MsgBox "Please enter a valid odometer reading", vbInformation, App.Title End If End Sub




Reply With Quote