CHERCHER UNE CHAINE DE CARACTÈRE DANS UNE AUTRE (+EXPLICATIONS)
Jeje Software®
Messages postés12Date d'inscriptionvendredi 5 octobre 2001StatutMembreDernière intervention24 juin 2002
-
9 avril 2002 à 14:09
Master_Kanter
Messages postés8Date d'inscriptionsamedi 7 juillet 2007StatutMembreDernière intervention28 février 2008
-
27 févr. 2008 à 00:55
Cette discussion concerne un article du site. Pour la consulter dans son contexte d'origine, cliquez sur le lien ci-dessous.
Master_Kanter
Messages postés8Date d'inscriptionsamedi 7 juillet 2007StatutMembreDernière intervention28 février 2008 27 févr. 2008 à 00:55
si kkun pouvai maider sa serai cool merci :)
Master_Kanter
Messages postés8Date d'inscriptionsamedi 7 juillet 2007StatutMembreDernière intervention28 février 2008 27 févr. 2008 à 00:54
salut je voudrai utiliser ton code mai j'ai un petit souci sa ne marche pa avec la chaine de carctere ke j'utilise
Private Sub Command1_Click()
Dim ligne As String
Dim Cobra
'je voudrai recupérer le 20
ligne = "Cobra : 20"
MsgBox SearchText(ligne, "Cobra : ", False), , ""
Cobra = SearchText(ligne, "Cobra : ", False)
Text2.Text = Cobra * 32
End Sub
Jeje Software®
Messages postés12Date d'inscriptionvendredi 5 octobre 2001StatutMembreDernière intervention24 juin 2002 13 avril 2002 à 01:16
;)
cs_GiZmO
Messages postés9Date d'inscriptionsamedi 2 février 2002StatutMembreDernière intervention27 juin 2002 10 avril 2002 à 18:47
pas mal
@+
GiZmO
Orthonic
Messages postés47Date d'inscriptionmardi 9 avril 2002StatutMembreDernière intervention 7 mars 2008 9 avril 2002 à 23:51
Tu as bien travaillé, ton code très propre, n'oublie pas de placer un test, quand le séparateur n'existe pas tu as une erreur.
J'ai une solution plus simple avec Instr et InstrRev :
Function SearchText(ByVal Chaine As String, ByVal Separateur As String, Optional ByVal Gauche As Boolean) As String
Dim Position As Integer
If Gauche = True Then
Position = InStrRev(Chaine, Separateur)
If Position <> 0 Then
SearchText = Mid$(Chaine, 1, Position - 1)
End If
Else
Position = InStr(1, Chaine, Separateur)
If Position <> 0 Then
SearchText = Mid$(Chaine, Position + 1)
End If
End If
End Function
Jeje Software®
Messages postés12Date d'inscriptionvendredi 5 octobre 2001StatutMembreDernière intervention24 juin 2002 9 avril 2002 à 14:09
Pour ceux qui ne comprenent toujours pas qu'ils me mail
27 févr. 2008 à 00:55
27 févr. 2008 à 00:54
Private Sub Command1_Click()
Dim ligne As String
Dim Cobra
'je voudrai recupérer le 20
ligne = "Cobra : 20"
MsgBox SearchText(ligne, "Cobra : ", False), , ""
Cobra = SearchText(ligne, "Cobra : ", False)
Text2.Text = Cobra * 32
End Sub
13 avril 2002 à 01:16
10 avril 2002 à 18:47
@+
GiZmO
9 avril 2002 à 23:51
J'ai une solution plus simple avec Instr et InstrRev :
Function SearchText(ByVal Chaine As String, ByVal Separateur As String, Optional ByVal Gauche As Boolean) As String
Dim Position As Integer
If Gauche = True Then
Position = InStrRev(Chaine, Separateur)
If Position <> 0 Then
SearchText = Mid$(Chaine, 1, Position - 1)
End If
Else
Position = InStr(1, Chaine, Separateur)
If Position <> 0 Then
SearchText = Mid$(Chaine, Position + 1)
End If
End If
End Function
9 avril 2002 à 14:09