Sign in to follow this  
Followers 0
ptrex

Parameter Function With Input Validation

3 posts in this topic

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

Share this post


Link to post
Share on other sites



overall, it looks good... however

'Amortisation'

is "Amortization"

and i dont understand the "1-1/"

"0 /" anynumber would be incorrect to me ( AFAIK )

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Share this post


Link to post
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
Sign in to follow this  
Followers 0