OVH Cloud OVH Cloud

extraire une chaine

2 réponses
Avatar
Bonjour,

voila je me pose la question suivante :
j'ai un champ qui contient des données du genre " RPM 90 174 # 1504"
j'ai besoin de récupérer le texte du champ à partir du symbole # jusqu'à la
fin du champ.
Coment je peux faire ça en VBA ?

merci beaucoup si vous savez.

2 réponses

Avatar
Eric
Bonjour,

Je ne sais pas où tu comptes utiliser ce traitement.
Si c'est dans une requête, tu peux directement utiliser les fonctions
ExtracChaîne()ou Mid() et DansChaîne() ou Instr(), du genre:
ExtracChaîne([UnChamp];DansChaîne([UnChamp];"#")+1)



ou avec une fonction du genre, dans un module global :
Public Function fnRetour(UnChamp) As String
If IsNull(UnChamp) Then Exit Function
fnRetour = Mid(UnChamp, InStr(UnChamp, "#") + 1)
End Function

S'il peut y avoir plus d'un # dans le champ, pour ne prendre qu àprès le
dernier #: Utiliser InstrRev() ' Access2K et +

ExtracChaîne([Equipe];InstrRev([Equipe];"#")+1)
ou encore
Public Function fnRetour2(UnChamp) As String
If IsNull(UnChamp) Then Exit Function
fnRetour2 = Mid(UnChamp, InStrRev(UnChamp, "#") + 1)
End Function

Si access97, voir la fonction équivalente à InstrRev chez Jessy:
http://access.jessy.free.fr/index.html?Menu&Page=fInStrRev

Bonjour,

voila je me pose la question suivante :
j'ai un champ qui contient des données du genre " RPM 90 174 # 1504"
j'ai besoin de récupérer le texte du champ à partir du symbole # jusqu'à la
fin du champ.
Coment je peux faire ça en VBA ?

merci beaucoup si vous savez.




--
A+
Eric
http://www.mpfa.info/
Archives : http://groups.google.fr/group/microsoft.public.fr.access?hl=fr

Avatar
merci, je vais me servir de instr

"Eric" a écrit dans le message de news:

Bonjour,

Je ne sais pas où tu comptes utiliser ce traitement.
Si c'est dans une requête, tu peux directement utiliser les fonctions
ExtracChaîne()ou Mid() et DansChaîne() ou Instr(), du genre:
ExtracChaîne([UnChamp];DansChaîne([UnChamp];"#")+1)



ou avec une fonction du genre, dans un module global :
Public Function fnRetour(UnChamp) As String
If IsNull(UnChamp) Then Exit Function
fnRetour = Mid(UnChamp, InStr(UnChamp, "#") + 1)
End Function

S'il peut y avoir plus d'un # dans le champ, pour ne prendre qu àprès le
dernier #: Utiliser InstrRev() ' Access2K et +

ExtracChaîne([Equipe];InstrRev([Equipe];"#")+1)
ou encore
Public Function fnRetour2(UnChamp) As String
If IsNull(UnChamp) Then Exit Function
fnRetour2 = Mid(UnChamp, InStrRev(UnChamp, "#") + 1)
End Function

Si access97, voir la fonction équivalente à InstrRev chez Jessy:
http://access.jessy.free.fr/index.html?Menu&Page=fInStrRev

Bonjour,

voila je me pose la question suivante :
j'ai un champ qui contient des données du genre " RPM 90 174 # 1504"
j'ai besoin de récupérer le texte du champ à partir du symbole # jusqu'à
la fin du champ.
Coment je peux faire ça en VBA ?

merci beaucoup si vous savez.


--
A+
Eric
http://www.mpfa.info/
Archives : http://groups.google.fr/group/microsoft.public.fr.access?hl=fr