All pastes #483029 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-05-11 15:09 UTC
rendered paste body
**Interest Calculation**




Private Sub cmdCalculate_Click()
    Dim strOutput As String
    Dim sngTotal As Single
    'If error occurs, go to end of the routine to print error message
    On Error GoTo ErrorHandler
    
    'Calculate future value
    sngTotal = Fix(txtDeposit.Text * _
    (1 + (txtInterest.Text / 100)) ^ txtYears.Text)
    
    'Make output visible
    strOutput = "Amount in savings after " & txtYears.Text & _
        " years is $" & Format(sngTotal, "###.00")
    lblOutput.Caption = strOutput
    lblOutput.Visible = True
    
    'End procedure
    Exit Sub

'Error Handler
ErrorHandler:
    MsgBox ("The values you entered resulted in an error. Try Again.")
    Exit Sub
End Sub

Private Sub cmdExit_Click()
    End
End Sub
Private Sub txtDeposit_GotFocus()
    txtDeposit.SelStart = 0
    txtDeposit.SelLength = Len(txtDeposit.Text)
End Sub
Private Sub txtInterest_GotFocus()
    txtInterest.SelStart = 0
    txtInterest.SelLength = Len(txtInterest.Text)
End Sub
Private Sub txtYears_GotFocus()
    txtYears.SelStart = 0
    txtYears.SelLength = Len(txtYears.Text)
End Sub






**Library**




Private Sub cmdCalculate_Click()
    Dim strFullname As String
    Dim sngFine As Single
    
    'Combine first and last name
    strFullname = txtFirst.Text & " " & txtLast.Text
    
    'Calculate late fee
    sngFine = Val(txtBooks.Text) * Val(txtWeeks.Text) * 0.05
    
    'Display Results
    lblOutput.Caption = strFullname & " owes " & Format(sngFine, "$###.00")
    lblOutput.Visible = True
End Sub

Private Sub cmdExit_Click()
    End
End Sub
Private Sub txtFirst_GotFocus()
    txtFirst.SelStart = 0
    txtFirst.SelLength = Len(txtFirst.Text)
End Sub
Private Sub txtLast_GotFocus()
    txtLast.SelStart = 0
    txtLast.SelLength = Len(txtLast.Text)
End Sub
Private Sub txtBooks_GotFocus()
    txtBooks.SelStart = 0
    txtBooks.SelLength = Len(txtBooks.Text)
End Sub
Private Sub txtWeeks_GotFocus()
    txtWeeks.SelStart = 0
    txtWeeks.SelLength = Len(txtWeeks.Text)
End Sub




**Transportation**
Private Sub cmdCalculate_Click()
    'Disable button
    cmdCalculate.Enabled = False
    
    'Calculate buses needed
    lblBusesNeeded.Caption = Val(txtPeople.Text) \ Val(txtPeoplePerBus.Text)
    
    'Calculate extra people
    lblExtra.Caption = Val(txtPeople.Text) Mod Val(txtPeoplePerBus.Text)
    
    'Display results
    lblLabel1.Visible = True
    lblLabel2.Visible = True
    lblBusesNeeded.Visible = True
    lblExtra.Visible = True
End Sub

Private Sub cmdExit_Click()
    End
End Sub

Private Sub txtPeople_Change()
    cmdCalculate.Enabled = True
End Sub

Private Sub txtPeople_GotFocus()
    txtPeople.SelStart = 0
    txtPeople.SelLength = Len(txtPeople.Text)
End Sub

Private Sub txtPeoplePerBus_Change()
    cmdCalculate.Enabled = True
End Sub

Private Sub txtPeoplePerBus_GotFocus()
    txtPeopleBus.SelStart = 0
    txtPeopleBus.SelLength = Len(txtPeople.Text)
End Sub