4 messages in org.openoffice.fr.progFonctions perso et paramètre optionnel
FromSent OnAttachments
christianwtdOct 30, 2006 12:21 pm 
Lionel CorgnetOct 30, 2006 12:36 pm 
christianwtdOct 30, 2006 12:56 pm 
Laurent GodardOct 30, 2006 11:55 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Fonctions perso et paramètre optionnelActions...
From:christianwtd (chri@free.fr)
Date:Oct 30, 2006 12:21:02 pm
List:org.openoffice.fr.prog

Bonjour à tous,

Je cherche à faire une fonction perso dans Calc et je bute sur les paramètres optionnels. Pour faire simple, un exemple... simple :

Function Bidon(Param1, Param2) Bidon = Param1 + Param2 End Function

Dans Calc, je fais : =BIDON(10; 20) et j'ai en retour 30. OK, ça marche. Mais si je souhaite le 2ème paramètre en option et que j'entre : =BIDON(10) J'ai droit à une erreur : Runtime error BASIC. L'argument n'est pas facultatif. Donc je me dis que je vais tester avec : IsMissing(Param2) Ca ne marche pas. Même erreur.

Donc je vais tester avec : On Error Goto TraiteErreurs et je fais faire :

Function Bidon(Param1, Param2) On Error Goto TraiteErreurs Bidon = Param1 + Param2 Exit Function ' TraiteErreurs: Resume Next Return End Function

Cette fois ci plus d'affichage de résultat. Je teste donc :

Function Bidon(Param1, Param2) On Error Goto TraiteErreurs Bidon = Param1 + Param2 Exit Function ' TraiteErreurs: Param2 = 0 Resume Next Return End Function

Encore une déconvenue. La fonction s'arrête à Param2=0 et donc pas de résultat.

Je tourne en rond. Je pense que j'ai raté quelque chose, mais avant de commencer à taper méchamment sur le clavier, peut-être avez-vous la solution.

D'avance merci,

Bon surf, Christian