DHN93160
Messages postés33Date d'inscriptionmercredi 29 décembre 2004StatutMembreDernière intervention12 janvier 2006
-
25 oct. 2005 à 10:19
NicoSoftt
Messages postés106Date d'inscriptionlundi 16 décembre 2002StatutMembreDernière intervention28 octobre 2005
-
25 oct. 2005 à 12:32
CHERS DEVELOPPEURS,DEVELOPTRICE,
J'AI UN FICHIER TEXTE D'UNE TRENTAINE DE LIGNES AVEC POUR CHAQUE LIGNE LES DONNEES TELS QUE : NOM,PRENOM,ADRESSE,CP,DEPT,PAYS (SANS MARQUE DE SEPARATION DE CHAMPS). A L'AIDE DE VB, J'AI CREE UN FORMULAIRE AVEC UN TEXTBOX POUR NOM,PRENOM,ADRESSE,CP,DEPT,PAYS ET DEUX COMMANDBUTTON:MAJ ET NEXT.
MON BUT EST DE FAIRE APPARAITRE LES DONNEES DANS LES TEXTBOX ADEQUATES EN CLIQUANT SUR MAJ ET AFFICHER LA 2EME LIGNE EN CLIQUANT SUR NEXT ET AINSI DE SUITE. POURRIEZ VOUS M'INDIQUER LES LIGNES DE COMMANDE POUR CE PETIT PROGRAMME.
EN ESPERANT DE VOTRE AIDE. MERCI MILLE FOIS
NicoSoftt
Messages postés106Date d'inscriptionlundi 16 décembre 2002StatutMembreDernière intervention28 octobre 2005 25 oct. 2005 à 11:55
Comment veux-tu séparer les données pour les différents champs s'il n'y a aucun séparateur (même pas un espace ?) ?
En attendant pour lire ligne par ligne tu peux utilisr l'instruction Input Line
Private Sub Form_Load()
Open fichier For Input As 1
End Sub
Private Sub Form_Unload(Cancel As Integer)
Close 1
End Sub
Private Sub Next_Click()
Line Input #1, temp
text1.Text = temp
End Sub
NicoSoftt
Messages postés106Date d'inscriptionlundi 16 décembre 2002StatutMembreDernière intervention28 octobre 2005 25 oct. 2005 à 12:32
Si tu les sépare par un ";", il faut fairze attention qu'il n'y ait aucun ";" dans les données Nom,prénom,Adresse,Cp,Dépt,Pays !
du type: NOM;PRÉNOM;ADRESSE;CP;DEPT;PAYS
exemple: Anne;Onyme;212, avenue de l'inconnue;00000;Inconnu-sur-Seine;AnonymLand
Dans ce cas le code sera :
'Noms des textbox (il y a un index)
'info(0) <=> nom
'info(1) <=> prénom
'info(2) <=> adresse
'...etc.
Private Sub Form_Load()
Open fichier For Input As 1 'fichier:ton fichier
End Sub
Private Sub Form_Unload(Cancel As Integer)
Close 1
End Sub
Private Sub Next_Click()
On Error GoTo fin
Line Input #1, temp
k = 0
j = 1
For i = 1 To Len(temp)
If Mid$(temp, i, 1) = ";" Then
Info(k) = Mid$(temp, j, i - j)
j = i + 1
k = k + 1
End If
Next i
Info(5) = Mid$(temp, j, i - j)
Exit Sub
fin: If Err = 62 Then MsgBox "Fin de fichier", vbInformation
End Sub