Tristanie
Messages postés4Date d'inscriptionlundi 16 janvier 2006StatutMembreDernière intervention18 janvier 2006
-
17 janv. 2006 à 23:15
Tristanie
Messages postés4Date d'inscriptionlundi 16 janvier 2006StatutMembreDernière intervention18 janvier 2006
-
18 janv. 2006 à 02:17
Bonsoir
J'ai qques soucis avec un programme en vb. en fait j'ai modifier un fichier à accès direct en y ajoutant un champ. jusque là tout va bien. Seul problème c'est qu'en lisant avec le programme, meme en modifiant les variables pour y mettre le nouveau champ, il semble y avoir un décalage dans mes données
il n'arrive plus à lire au dessus de 10 clients (surement du à un décalage??)si qqu avait un peu de temps à me consacré pour que je puisse transmettre les sources, mieux expliquer afin d'essayer à trouver la solution : tristanie@hotmail.com
Tristanie
Messages postés4Date d'inscriptionlundi 16 janvier 2006StatutMembreDernière intervention18 janvier 2006 18 janv. 2006 à 02:17
c'est bon problème résolu.
Private Sub Bajout_Click()
Open App.Path & "\CLIENTS.BAK" For Random As #1 Len = Len(FichClient)
Open App.Path & "\CLIENTS.DAT" For Random As #2 Len = Len(FichClient2)
PstClt = 0
I = 0
' Boucle de recherche
Do While Not EOF(1)
I = I + 1
Get #1, I, FichClient
Call EcrireClt
' On sort de la boucle dès que le client est trouvé ou qu'on atteind la fin du fichier
Loop
Close
Bajout.Enabled = False
End Sub
cs_CanisLupus
Messages postés3757Date d'inscriptionmardi 23 septembre 2003StatutMembreDernière intervention13 mars 200621 17 janv. 2006 à 23:28
Salut,
Si ta source n'est pas trop volumineuse, colle-là ici.
Sinon, explique comment tu lis ou modifies ce fichier, et surtout le type et la structure de ce fichier. Je pense à un fichier texte, je me trompe ? Si oui, précise-nous le type de ton fichier.
-------------------------------------------------
Dresseur de puces, .... normal pour un loup !?
Tristanie
Messages postés4Date d'inscriptionlundi 16 janvier 2006StatutMembreDernière intervention18 janvier 2006 17 janv. 2006 à 23:38
Alors jespère que ce sera compréhensible ^^
Exemple du contenu du fichier data:
00000110 ADVERTISING Wolbecker Strabe 36 F-92400 COURBEVOIE 01 70 37 41 13 01 70 37 41 01 000002141 FRANCE 11 Rue Galvani F-75008 PARIS 01 70 37 41 13 01 70 37 41 01 000003141 FRANCE ROMESTRAAT 11 F-75945 PARIS
ce sont des données fausses bien entendu (g mis en évidence les numéros ) yen a 3500
Programme pour ajouter un champ: Sub EcrireClt()
FichClient2.Num = FichClient.Num
FichClient2.Nom = FichClient.Nom
FichClient2.RaisonSoc = FichClient.RaisonSoc
FichClient2.Adresse1 = FichClient.Adresse1
FichClient2.Adresse2 = FichClient.Adresse2
FichClient2.CodePostal = FichClient.CodePostal
FichClient2.Localite = FichClient.Localite
FichClient2.Telephone = FichClient.Telephone
FichClient2.Telecopie = FichClient.Telecopie
FichClient2.Gsm = Egsm.Text
Put #2, , FichClient2
End Sub
Private Sub Bajout_Click()
Open App.Path & "\CLIENTS.BAK" For Random As #1 Len = Len(FichClient)
Open App.Path & "\CLIENTS.DAT" For Random As #2 Len = Len(FichClient2)
' Initialisation de la recherche
TrouveClt = False
PstClt = 0
I = 1
' Boucle de recherche
Do
I = I + 1
Get #1, I, FichClient
Call EcrireClt
' On sort de la boucle dès que le client est trouvé ou qu'on atteind la fin du fichier
Loop Until (I = 3500) Or TrouveClt
Close
End Sub
Private Sub BSauv_Click()
FileCopy App.Path & "\CLIENTS.DAT", App.Path & "\CLIENTS.BAK"
BSauv.Enabled = False
Bajout.Enabled = True
End Sub
Private Sub Form_Load()
Bajout.Enabled = False
End Sub
-------------------------------------------------------------------------------------------------------------------------
avec le module:
Public Type tClients
Num As String * 6
Nom As String * 30
RaisonSoc As String * 10
Adresse1 As String * 30
Adresse2 As String * 30
CodePostal As String * 12
Localite As String * 20
Telephone As String * 20
Telecopie As String * 20
End Type
Public Type tClients2
Num As String * 6
Nom As String * 30
RaisonSoc As String * 10
Adresse1 As String * 30
Adresse2 As String * 30
CodePostal As String * 12
Localite As String * 20
Telephone As String * 20
Telecopie As String * 20
'ajout d'un champ
Gsm As String * 20
End Type
Public I As Integer
Public FichClient As tClients
Public FichClient2 As tClients2
Public NbClt, PstClt As Integer
Public TrouveClt As Boolean
--------------------------------------------------------------------------------------------------------------------------------
Programme pour lire:
Sub EcrireClt()
FichClient.Num = eNumClt.Text
FichClient.Nom = eNom.Text
FichClient.RaisonSoc = eRaisonSoc.Text
FichClient.Adresse1 = eAdresse1.Text
FichClient.Adresse2 = eAdresse2.Text
FichClient.CodePostal = eCodePostal.Text
FichClient.Localite = eLocalite.Text
FichClient.Telephone = eTelephone.Text
FichClient.Telecopie = eTelecopie.Text
FichClient.Gsm = eGsm.Text
Put #1, PstClt, FichClient
End Sub
Sub RechercherClt()
Dim I As Integer
' Initialisation de la recherche
TrouveClt = False
PstClt = 0
I = 1
' Boucle de recherche
Do
I = I + 1
Get #1, I, FichClient
If (FichClient.Num = eNumClt.Text) Then
PstClt = I
TrouveClt = True
End If
' On sort de la boucle dès que le client est trouvé ou qu'on atteind la fin du fichier Loop Until (I NbClt) Or (PstClt I)
If (Not TrouveClt) Then
MsgBox "Aucun client ne correspond aux critères de recherche"
PstClt = 0 'La position est remise à ZERO au cas où la fiche trouvée est une fiche supprimée
End If
End Sub
Private Sub bAjouter_Click()
Dim I As Integer
' Initialisation de la recherche
TrouveClt = False
PstClt = 0
I = 1
' Boucle de recherche
Do
I = I + 1
Get #1, I, FichClient
If (FichClient.Num = eNumClt.Text) Then
TrouveClt = True
End If
' On sort de la boucle dès que le client est trouvé ou qu'on atteind la fin du fichier
Loop Until (I = NbClt) Or TrouveClt
If Not TrouveClt Then
NbClt = NbClt + 1
PstClt = NbClt
Call EcrireClt
Call bInitialiser_Click
Else
MsgBox "Ce numéro de client a déjà été utilisé."
eNumClt.SetFocus
End If
End Sub
Private Sub bModifier_Click()
Call EcrireClt
End Sub
Private Sub bQuitter_Click()
Call mQuitter_Click
End Sub
Private Sub bRechercher_Click()
PstClt = 0
If eNumClt.Text > "" Then Call RechercherClt
'Si un client est trouvé, il est affiché
If PstClt > 0 Then AfficheClt Else bInitialiser_Click
End Sub
Private Sub eNom_Change()
bAjouter.Enabled = (eNumClt.Text > "") And (eNom.Text > "")
bModifier.Enabled = (eNumClt.Text > "") And (eNom.Text > "") And (Not eNumClt.Enabled)
End Sub
Private Sub eNumClt_Change()
bRechercher.Enabled = (eNumClt.Text > "") And (eNumClt.Enabled)
bAjouter.Enabled = (eNumClt.Text > "") And (eNom.Text > "") And (eNumClt.Enabled)
End Sub
Private Sub eNumClt_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 And bRechercher.Enabled Then
KeyAscii = 0
Call eNumClt_LostFocus
Call bRechercher_Click
End If
If ((Chr(KeyAscii) < "0") Or (Chr(KeyAscii) > "9")) And (KeyAscii <> 8) Then KeyAscii = 0
End Sub
Private Sub eNumClt_LostFocus()
If eNumClt.Text > "" Then
While Len(eNumClt.Text) < 6
eNumClt.Text = "0" + eNumClt.Text
Wend
End If
End Sub
Private Sub Form_Load()
'Ouverture du fichier clients et lecture du nombre d'enregistrements
Open "Data\CLIENTS.DAT" For Random As #1 Len = Len(FichClient)
Get #1, 1, FichClient If Val(FichClient.Nom) <> 0 Then NbClt Val(FichClient.Nom) Else NbClt 1
End Sub
Private Sub mQuitter_Click()
'Enregistrement du nombre de clients et fermeture du fichier
Dim quitter As Integer
quitter = MsgBox("Voulez-vous quitter?", vbYesNo, "Fin de programme")
If quitter = 6 Then
FichClient.Nom = Str(NbClt)
Put #1, 1, FichClient
Close #1
End
'Fermeture du programme
End If
End Sub
----------------------------------------------------------------------------------------------------------------------------
module attaché au programme de lecture:
Public Type tClients
Num As String * 6
Nom As String * 30
RaisonSoc As String * 10
Adresse1 As String * 30
Adresse2 As String * 30
CodePostal As String * 12
Localite As String * 20
Telephone As String * 20
Telecopie As String * 20
Gsm As String * 20
End Type
Public FichClient As tClients
Public NbClt, PstClt As Integer
Public TrouveClt As Boolean
-------------------------------
voilà jepère que c'est pas trop gros
fin sinon [mailto:tristanie@hotmail.com tristanie@hotmail.com] jpe envoyer ça compressé ce serait plus facile :p
donc en fait le prob c'est ptet tout simplement dans léditeur :s