Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionprivate function GetCtrlByName(byval pName as string, byref pFrm as form) as Object Dim lCtrlName as string Dim lCtrlIndex as long Dim lCtrl as object If instr(pName,"(")<>0 then lCtrlName =split(pName,"(")(0) lCtrlIndex =val(replace(split(pName,"(")(1),")",""))) else lCtrlName =pName lCtrlIndex =-1 End if for each lCtrl in pFrm.Controls if lctrl.name=lctrlName then if lCtrl.index=lctrlIndex or lctrlIndex =-1 then set GetCtrlByName=lCtrl Exit Function end if end if next set GetCtrlByName=Nothing End function
toto = "P371(1)" nomobj = toto pos = InStr(toto, "(") If pos Then indexobj = Val(Mid(toto, pos + 1)) nomobj = Left(toto, pos - 1) End If MsgBox nomobj & vbCrLf & indexobj