Jump to content

Parameter Function With Input Validation


Recommended Posts

In this function I have created some input validations.

MsgBox(262144,'Debug_Loan_Amortisation',_Loan_Amortisation(10000,3,24));### Debug MSGBOX
 
Func _Loan_Amortisation($A,$B,$C)
    Local $D, $E
    If BitAND(IsNumber($A),$A>0) And BitAND(IsNumber($B),$B>0,$B<=100) And BitAND(IsInt($C),$C>0) Then
        $E=$B/100;
        $D=$A*($E/12)/(1-1/(EXP($C*LOG(1+$E/12))))
            SetError(0)
            Return $D
    Else
        SetError(1)
        Return 0
    EndIf
EndFunc;==>_Loan_Amortisation

As you can see the If BtAND( ... does the validation to check if it's a number, integer and some values must be <=100,etc.

I am wondering if this is the only way to do it ?

I would like to see some alternatives if possible.

Thanks

Link to comment
Share on other sites

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...