Bonjour,
Je fait une lecture d'un fichier texte par
Tout ce passe bien, j'ai meme changer l'extention des fichiers.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 Dim MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser("C:\dossier\ab.txt") MyReader.TextFieldType = FileIO.FieldType.Delimited MyReader.SetDelimiters(",")
Le probléme vien du fait que je n'arrive pas à modifié un fichier et je n'arrive pas, non plus, de créé un nouveau fichier.
PS, j'utilise sa pour lire les données d'un fichier
je pence que Select case est nul d'un point de vue programmation
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70 While Not MyReader.EndOfData Try Dim boucle As Integer currentRow = MyReader.ReadFields() boucle = currentRow.Length Select Case currentRow.Length Case 1 Me.TextBoxNumPlan.Text = currentRow(0) Me.TextBoxDescription.Text = "" Me.TextBoxIndice.Text = "" Me.TextBoxDateIndice.Text = "" Me.TextBoxLocalisation.Text = "" Me.TextBoxUnité.Text = "" Me.TextBoxEnsembleFonctionnel.Text = "" Case 2 Me.TextBoxNumPlan.Text = currentRow(0) Me.TextBoxDescription.Text = currentRow(1) Me.TextBoxIndice.Text = "" Me.TextBoxDateIndice.Text = "" Me.TextBoxLocalisation.Text = "" Me.TextBoxUnité.Text = "" Me.TextBoxEnsembleFonctionnel.Text = "" Case 3 Me.TextBoxNumPlan.Text = currentRow(0) Me.TextBoxDescription.Text = currentRow(1) Me.TextBoxIndice.Text = currentRow(2) Me.TextBoxDateIndice.Text = "" Me.TextBoxLocalisation.Text = "" Me.TextBoxUnité.Text = "" Me.TextBoxEnsembleFonctionnel.Text = "" Case 4 Me.TextBoxNumPlan.Text = currentRow(0) Me.TextBoxDescription.Text = currentRow(1) Me.TextBoxIndice.Text = currentRow(2) Me.TextBoxDateIndice.Text = currentRow(3) Me.TextBoxLocalisation.Text = "" Me.TextBoxUnité.Text = "" Me.TextBoxEnsembleFonctionnel.Text = "" Case 5 Me.TextBoxNumPlan.Text = currentRow(0) Me.TextBoxDescription.Text = currentRow(1) Me.TextBoxIndice.Text = currentRow(2) Me.TextBoxDateIndice.Text = currentRow(3) Me.TextBoxLocalisation.Text = currentRow(4) Me.TextBoxUnité.Text = "" Me.TextBoxEnsembleFonctionnel.Text = "" Case 6 Me.TextBoxNumPlan.Text = currentRow(0) Me.TextBoxDescription.Text = currentRow(1) Me.TextBoxIndice.Text = currentRow(2) Me.TextBoxDateIndice.Text = currentRow(3) Me.TextBoxLocalisation.Text = currentRow(4) Me.TextBoxUnité.Text = currentRow(5) Me.TextBoxEnsembleFonctionnel.Text = "" Case 7 To 999 Me.TextBoxNumPlan.Text = currentRow(0) Me.TextBoxDescription.Text = currentRow(1) Me.TextBoxIndice.Text = currentRow(2) Me.TextBoxDateIndice.Text = currentRow(3) Me.TextBoxLocalisation.Text = currentRow(4) Me.TextBoxUnité.Text = currentRow(5) Me.TextBoxEnsembleFonctionnel.Text = currentRow(6) End Select Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException MsgBox("Line " & ex.Message & "is not valid and will be skipped.") End Try End While
(j'ai fait sa pour filter les fichier mal au point, ou les fichier ou ils manque des données)
Partager