j'ai écris le petit bout de code ci-dessous pour extraire le nom et le
prénom d'une chaine de caractère.
je ne sais pas comment je demande à la fonction de retourner les deux
éléments "nom" et "prenom" pour pouvoir les afficher dans test1
Function test(contact As String)
Position = InStr(1, contact)
prenom = Left(texte, Position)
nom = Right(texte, (Len(contact) - Position))
End Function
Sub test1()
tab_contact = test("jean vasseur")
MsgBox toto(1)
End Sub
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
JpPradier
Bonjour jean
En modifiant ta macro comme suit, ca devrait aller :
Function test(contact As String) Dim Tout(2) Position = InStr(1, contact, " ") prenom = Left(contact, Position - 1) nom = Right(contact, (Len(contact) - Position)) Tout(0) = prenom Tout(1) = nom test = Tout End Function
Sub test1() tab_contact = test("jean vasseur")
MsgBox tab_contact(0) & " " & tab_contact(1) End Sub
j-p
Bonjour jean
En modifiant ta macro comme suit, ca devrait aller :
Function test(contact As String)
Dim Tout(2)
Position = InStr(1, contact, " ")
prenom = Left(contact, Position - 1)
nom = Right(contact, (Len(contact) - Position))
Tout(0) = prenom
Tout(1) = nom
test = Tout
End Function
Sub test1()
tab_contact = test("jean vasseur")
MsgBox tab_contact(0) & " " & tab_contact(1)
End Sub
En modifiant ta macro comme suit, ca devrait aller :
Function test(contact As String) Dim Tout(2) Position = InStr(1, contact, " ") prenom = Left(contact, Position - 1) nom = Right(contact, (Len(contact) - Position)) Tout(0) = prenom Tout(1) = nom test = Tout End Function
Sub test1() tab_contact = test("jean vasseur")
MsgBox tab_contact(0) & " " & tab_contact(1) End Sub
j-p
Jean
Merci beaucoup
Jean
"JpPradier" a écrit dans le message de news:
Bonjour jean
En modifiant ta macro comme suit, ca devrait aller :
Function test(contact As String) Dim Tout(2) Position = InStr(1, contact, " ") prenom = Left(contact, Position - 1) nom = Right(contact, (Len(contact) - Position)) Tout(0) = prenom Tout(1) = nom test = Tout End Function
Sub test1() tab_contact = test("jean vasseur")
MsgBox tab_contact(0) & " " & tab_contact(1) End Sub
j-p
Merci beaucoup
Jean
"JpPradier" <jp.pradier.JVeuxPasDeSpam@wanadoo.fr> a écrit dans le message
de news: uX7FAcxNGHA.2916@tk2msftngp13.phx.gbl...
Bonjour jean
En modifiant ta macro comme suit, ca devrait aller :
Function test(contact As String)
Dim Tout(2)
Position = InStr(1, contact, " ")
prenom = Left(contact, Position - 1)
nom = Right(contact, (Len(contact) - Position))
Tout(0) = prenom
Tout(1) = nom
test = Tout
End Function
Sub test1()
tab_contact = test("jean vasseur")
MsgBox tab_contact(0) & " " & tab_contact(1)
End Sub
En modifiant ta macro comme suit, ca devrait aller :
Function test(contact As String) Dim Tout(2) Position = InStr(1, contact, " ") prenom = Left(contact, Position - 1) nom = Right(contact, (Len(contact) - Position)) Tout(0) = prenom Tout(1) = nom test = Tout End Function
Sub test1() tab_contact = test("jean vasseur")
MsgBox tab_contact(0) & " " & tab_contact(1) End Sub