E.B.
Structure contacts Public num As String Public cat As String Public nom As String Public prenom As String Public adr As String Public vil As String Public cp As String Public digi As String Public tel As String Public mob As String Public fax As String Public mail As String Public adr2 As String Public vil2 As String Public cp2 As String Public digi2 As String Public tel2 As String Public fax2 As String Public comm As String End Structure Public contact(5000) As contacts Public nbrctc As Integer
Public Sub ecritperson() With contact(nbrctc) .num = nbrctc .cat = Cbxcat.Text .nom = Textnom.Text .prenom = Textprénom.Text .adr = Textadr.Text .vil = TextVil.Text .cp = textcp.Text .digi = Textdig.Text .tel = TextPhone.Text .mob = TextMob.Text .fax = TextFax.Text .mail = Textmail.Text .adr2 = Textadr2.Text .vil2 = Textvil2.Text .cp2 = TextCp2.Text .digi2 = Textdigi2.Text .tel2 = Textphone2.Text .fax2 = Textfax2.Text .comm = Textcomments.Text End With Dim sr As StreamWriter = File.AppendText("\person.txt") sr.WriteLine(contact(nbrctc).num) sr.WriteLine(contact(nbrctc).cat) sr.WriteLine(contact(nbrctc).nom) sr.WriteLine(contact(nbrctc).prenom) sr.WriteLine(contact(nbrctc).adr) sr.WriteLine(contact(nbrctc).vil) sr.WriteLine(contact(nbrctc).cp) sr.WriteLine(contact(nbrctc).digi) sr.WriteLine(contact(nbrctc).tel) sr.WriteLine(contact(nbrctc).mob) sr.WriteLine(contact(nbrctc).fax) sr.WriteLine(contact(nbrctc).mail) sr.WriteLine(contact(nbrctc).adr2) sr.WriteLine(contact(nbrctc).vil2) sr.WriteLine(contact(nbrctc).cp2) sr.WriteLine(contact(nbrctc).digi2) sr.WriteLine(contact(nbrctc).tel2) sr.WriteLine(contact(nbrctc).fax2) sr.WriteLine(contact(nbrctc).comm) sr.Close() End Sub
Public Sub lecturectc() Dim sh As StreamReader = File.OpenText("\person.txt") With contact(nbrctc) nbrctc = .num Cbxcat.Text = .cat Textnom.Text = .nom Textprénom.Text = .prenom Textadr.Text = .adr TextVil.Text = .vil textcp.Text = .cp Textdig.Text = .digi TextPhone.Text = .tel TextMob.Text = .mob TextFax.Text = .fax Textmail.Text = .mail Textadr2.Text = .adr2 Textvil2.Text = .vil2 TextCp2.Text = .cp2 Textdigi2.Text = .digi2 Textphone2.Text = .tel2 Textfax2.Text = .fax2 Textcomments.Text = .comm End With nbrctc = sh.ReadLine Cbxcat.Text = sh.ReadLine Textnom.Text = sh.ReadLine Textprénom.Text = sh.ReadLine Textadr.Text = sh.ReadLine TextVil.Text = sh.ReadLine textcp.Text = sh.ReadLine Textdig.Text = sh.ReadLine TextPhone.Text = sh.ReadLine TextMob.Text = sh.ReadLine TextFax.Text = sh.ReadLine Textmail.Text = sh.ReadLine Textadr2.Text = sh.ReadLine Textvil2.Text = sh.ReadLine TextCp2.Text = sh.ReadLine Textdigi2.Text = sh.ReadLine Textphone2.Text = sh.ReadLine Textfax2.Text = sh.ReadLine Textcomments.Text = sh.ReadLine sh.Close() End Sub
Public Sub ecrire() FileOpen(1, "c:\person.txt", OpenMode.Binary) With contact(nbrctc) .num = nbrctc .cat = Cbxcat.Text & nbrctc .nom = Textnom.Text & nbrctc .prenom = Textprénom.Text & nbrctc .adr = Textadr.Text & nbrctc .vil = TextVil.Text & nbrctc .cp = textcp.Text & nbrctc .digi = Textdig.Text & nbrctc .tel = TextPhone.Text & nbrctc .mob = TextMob.Text & nbrctc .fax = TextFax.Text & nbrctc .mail = Textmail.Text & nbrctc .adr2 = Textadr2.Text & nbrctc .vil2 = Textvil2.Text & nbrctc .cp2 = TextCp2.Text & nbrctc .digi2 = Textdigi2.Text & nbrctc .tel2 = Textphone2.Text & nbrctc .fax2 = Textfax2.Text & nbrctc .comm = Textcomments.Text & nbrctc FilePut(1, contact) End With FileClose(1) End Sub
Public Sub lire() FileOpen(1, "C:\person.txt", OpenMode.Binary) With contact(nbrctc) nbrctc = .num Cbxcat.Text = .cat Textnom.Text = .nom Textprénom.Text = .prenom Textadr.Text = .adr TextVil.Text = .vil textcp.Text = .cp Textdig.Text = .digi TextPhone.Text = .tel TextMob.Text = .mob TextFax.Text = .fax Textmail.Text = .mail Textadr2.Text = .adr2 Textvil2.Text = .vil2 TextCp2.Text = .cp2 Textdigi2.Text = .digi2 Textphone2.Text = .tel2 Textfax2.Text = .fax2 Textcomments.Text = .comm FileGet(1, contact) End With FileClose(1) End Sub