jrivet
Messages postés7392Date d'inscriptionmercredi 23 avril 2003StatutMembreDernière intervention 6 avril 201260 26 oct. 2007 à 09:38
Salut,
Il y a sûrement plus simple mais regarde ceci...
Private Sub Form_Load()
Dim p As String
p = "M20"
MsgBox GetValue(p)
End Sub<hr />
Private Function GetValue(ByVal strVal As String) As String
Dim i As Integer
Dim Carac As String
'Pour chaque caractere de la chaine
For i = 1 To Len(strVal)
'on recupere le caractere
Carac = Mid(strVal, i, 1)
'si il est numerique on le stocke dans le résultat
If IsNumeric(Carac) Then GetValue = GetValue & Carac
Next
End Function , ----
[code.aspx?ID=41455 By Renfield]
jmfmarques
Messages postés7666Date d'inscriptionsamedi 5 novembre 2005StatutMembreDernière intervention22 août 201427 26 oct. 2007 à 11:40
Bonjour,
ou encore, si la chaîne ne contient qu'une valeur à extraire et qu'elle est différente de 0 :
Private Sub Command1_Click()
Dim toto As String
toto = "BCD25TD"
MsgBox valeurdans(toto)
End Sub
Private Function valeurdans(chaine As String) As Integer
For i = 1 To Len(chaine)
If IsNumeric(Mid(chaine, i, 1)) Then
chaine = Mid(chaine, i)
Exit For
End If
Next
valeurdans = Val(chaine)
End Function