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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
| Imports System.IO
Public Module Module1
Public hist(999999) As String
Public indice As Integer
End Module
Public Class Form2
Public AppPath As String = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly.GetName.CodeBase)
Sub lecturefichier(ByRef fichier As String)
Dim FichierTexte As String
Dim i As Integer
Dim Tableau(0) As String
Try
Dim ObjetFichier As StreamReader = New StreamReader(fichier)
Do
FichierTexte = ObjetFichier.ReadLine()
If FichierTexte Is Nothing Then
i = i - 1
Else
If i = 0 Then
ReDim Tableau(i)
Else
ReDim Preserve Tableau(i)
End If
Tableau(i) = FichierTexte
End If
i = i + 1
Loop Until FichierTexte Is Nothing
ObjetFichier.Close()
i = i - 1
Catch exc As Exception
MsgBox("Fichier inexistant")
End Try
hist = Tableau
End Sub
Public Sub EcrireFichier(ByVal CheminFichier As String, ByVal Texte As String)
Dim FreeF As Integer
FreeF = FreeFile() 'Possibilité de mettre 1
'Texte = Replace(Texte, vbLf, vbCrLf)
FileOpen(FreeF, CheminFichier, OpenMode.Output)
Print(FreeF, Texte)
FileClose(FreeF)
End Sub
Sub test(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
lecturefichier("Z:\test2.txt")
Dim tt() As String
Dim tabl(4, 2) As String
Label1.Text = hist(0).ToString
For i = 0 To 3
Dim truc As String = hist(i)
tt = Split(truc, "@")
Label2.Text = tt(0).ToString
For j = 0 To 2
tabl(i, j) = CStr(tt(j))
Next
Next
Label1.Text = tabl(1, 2).ToString
For k = 0 To 2
tabl(4, k) = k * 10 + 4
Next
Dim txtt(4) As String
Dim txt As String = Nothing
For li = 0 To 4
txtt(li) = CStr(tabl(li, 0)) & "@" & CStr(tabl(li, 1)) & "@" & CStr(tabl(li, 2)) & vbCrLf
Next
For co = 0 To 4
txt = txt & txtt(co)
Next
EcrireFichier("Z:\test3.txt", txt)
End Sub
End Class |
Partager