This coding was done by comatose he was awesome and extremely helpful in explaining and making a newbie like myself understand VB alittle more clearly. The comments were also done by comatose to help the user understand what he is actually doing step by step. Here is the complete program code. To make this project work.
' /* Declare Variables */
Dim hours
Dim total As Single
Dim mdiscount As Single
Dim pass As Integer
Dim card As Integer
Dim Plate As String
Dim fee As Integer
Dim feeRate As Single
Dim allDay As Integer
Dim FreeTime As Integer
Private Sub cmdExit_Click()
' /* This Code Unloads ALL THE FORMS in the project */
Dim XFrm
' /* For every Form in our project */
For Each XFrm In Forms
' /* Unload The Form */
Unload XFrm
Next XFrm
End Sub
Private Sub cmdOK_Click()
' /* Get The Value In The TextBox, and Return It as An Integer */
hours = txtParked.Text
' /* Get The Plate Number */
Plate = txtPlates.Text
' /* Check If They Left The Hours Blank */
If hours = "" Then
' /* If So alert the User */
MsgBox "Please Enter The Amount Of Time In The Parking Lot"
' /* Exit The Sub Routine */
Exit Sub
End If
' /* Check If They Left The License Plate Box Blank */
If Plate = "" Then
' /* If So, Alert the User */
MsgBox "Enter The License Plate"
' /* Exit This Sub */
Exit Sub
End If
If total >= 40 Then
total = 40
End If
' /* If They Don't have a pass */
If chkPass.Value = 0 Then
' /* They Get Three Hours Without being charged additional Time fee */
FreeTime = 3
' /* Set The Total They Owe To The Value Of Fee (10 bucks) */
total = fee
' /* If They DO Have A Pass */
ElseIf chkPass.Value = 1 Then
' /* They Get 12 Hours Free */
FreeTime = 12
' /* With No Charge */
total = 0
End If
' /* If They Have A Husky Pass */
If chkHusky.Value = 1 Then
' /* Add 5 Hours To The Free Time They Get Before Additional 3.25 Charge */
FreeTime = FreeTime + 5
End If
' /* Total Hours Will Be Hours Entered, Minus However much Time They Get Free */
hours = hours - FreeTime
' /* If Hours Is Less Than Or Equal To 0, They User Doesn't Owe Anything */
If hours <= 0 Then
' /* NO Charge */
total = 0
Else
' /* Otherwise, They Owe Something */
' /* So, set tmp to hours remaining (after free time) times 3.25 (feeRate) */
tmp = hours * feeRate
' /* Total Equals Total Ammount They Owe, PLUS The Value of Tmp (3.25 * whatever) */
total = total + tmp
End If
' /* If They are From a Crappy state */
If OptState.Value = True Then
' /* Add 5 to what they owe */
total = total + 5
End If
' /* If They Have A Merchant Pass */
If chkMerchant.Value = 1 Then
' /* Get 10 percent of the total */
tmp = total * mdiscount
' /* Subtract whatever 10% of the total is, from the total */
total = (total - tmp)
End If
If total >= 40 Then
total = 40
End If
' /* Set The Label To The Total */
lblCharge.Caption = total
End Sub
Private Sub Form_Load()
fee = 10
feeRate = 3.25
allDay = 40
mdiscount = 0.01
End Sub