Page 1 sur 1

Lotus script :::: if .... then

MessagePublié: 08 Mars 2012 à 14:20
par VastoMarine
Bonjour, Puis-je simplifier mon If imbriqué ? Merci

Forall xFieldname In oForm.Fields

If Cstr(xFieldname) = "fldExec1" then

If CStr(xFieldname) = "fldExec2" then

If CStr(xFieldname) = "fldExec3" Then

If CStr(xFieldname) = "fldExec4" Then

If CStr(xFieldname) = "fldExec5" Then

If CStr(xFieldname) = "fldExec6" Then

If CStr(xFieldname) = "fldExec7" Then




cont = 1

End If
End If
End If
End If
End If
End If
End If
End ForAll

Re: Lotus script :::: if .... then

MessagePublié: 08 Mars 2012 à 14:58
par gouff
Avec un select Case je pense

Re: Lotus script :::: if .... then

MessagePublié: 08 Mars 2012 à 15:33
par kochiz
Salut,

Effectivement le select cas est très approprié dans ton cas.

Re: Lotus script :::: if .... then

MessagePublié: 08 Mars 2012 à 16:34
par pivo
Je comprends pas ton (tes) if... Il faut qu'un champ s'appelle à la fois "fldExec1" et "fldExec2" et ... et "fldExec7" pour arriver à l'instruction "cont = 1" ??

Pas sûr que ça arrive souvent.

Sinon si tu veux vérifier qu'il existe au moins un champ nommé "fldExec[i]" je partirais sur un

If LCase(Left(xFieldname, 7)) = "fldexec" AND Cint(Right(xFieldname, 1) >= 1 AND Cint(Right(xFieldname, 1) <= 7 then
cont = 1
End if

Avec évt encore un test sur la longueur.