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
|
Using monReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(cheminfichier)
monReader.TextFieldType = FileIO.FieldType.FixedWidth
monReader.SetFieldWidths(4, 7, 30, 2, 7, 8, 8, 1, 8, -1)
Dim ligneCourante As String()
Dim afficheLigCourante As String = ""
Dim numChamp As Integer = 1
While Not monReader.EndOfData
Try
ligneCourante = monReader.ReadFields()
Dim champCourant As String = String.Empty
objFiche = New Fiche1
numChamp = 1
For Each champCourant In ligneCourante
Select Case numChamp
Case 1
objFiche.champ1 = CType(champCourant, String)
Case 2
objFiche.champ2 = CType(champCourant, String)
Case 3
objFiche.champ3 = CType(champCourant, String)
Case 4
objFiche.champ4 = CType(champCourant, String)
Case 5
objFiche.champ5 = CType(champCourant, String)
Case 6
objFiche.champ6 = CType(champCourant, String)
Case 7
objFiche.champ7 = CType(champCourant, String)
Case 8
objFiche.champ8 = CType(champCourant, String)
Case 9
objFiche.champ9 = CType(champCourant, String)
Case 10
objFiche.champ10 = CType(champCourant, String)
End Select
'champ suivant
numChamp = numChamp + 1
afficheLigCourante = afficheLigCourante & champCourant
afficheLigCourante = ""
Next
Call list1(objFiche)
'ligne suivant
'MsgBox(afficheLigCourante, MsgBoxStyle.DefaultButton1)
'afficheLigCourante = ""
'DataGridView1.DataSource = liste1
Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
MsgBox("Ligne " & ex.Message & "non valide,sera saute....")
End Try
End While
End Using |
Partager