88 lines
3.4 KiB
VB.net
88 lines
3.4 KiB
VB.net
Public Class Form1
|
|
Dim nf As Integer
|
|
Structure PERS
|
|
<VBFixedString(8)> Dim Nom As String
|
|
<VBFixedString(6)> Dim Prenom As String
|
|
<VBFixedString(10)> Dim Adresse As String
|
|
<VBFixedString(5)> Dim CP As Integer
|
|
<VBFixedString(15)> Dim Ville As String
|
|
<VBFixedString(5)> Dim Age As Integer REM Stocke la date de naissance en mois (plus facile pour convertir après)
|
|
<VBFixedString(1)> Dim Region As Integer REM Stocke l'index
|
|
<VBFixedArray(3)> Dim Ecrit() As Integer REM index
|
|
<VBFixedArray(2)> Dim Oral() As Integer REM index
|
|
<VBFixedString(2)> Dim Fac As Integer REM Stocke l'index
|
|
End Structure
|
|
Dim cddts As PERS
|
|
Dim NbPers As Integer
|
|
Dim lght As Integer
|
|
|
|
|
|
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
|
|
ReDim cddts.Ecrit(3)
|
|
ReDim cddts.Oral(2)
|
|
lght = Len(cddts)
|
|
'
|
|
'nf = FreeFile()
|
|
'FileOpen(nf, "Candidats.C7P", OpenMode.Random, OpenAccess.ReadWrite, OpenShare.Shared, lght)
|
|
|
|
'FileGet(nf, cddts, 1)
|
|
'Label1.Text = cddts.CP
|
|
|
|
'Dim i As Integer
|
|
'For i = 1 To 5
|
|
' FileGet(nf, cddts, i)
|
|
' ListBox1.Items.Add(cddts.Nom & " " & cddts.Prenom & " " & cddts.Adresse & " " & cddts.CP & " " & cddts.Ville & " " & cddts.Age & " " & cddts.Ecrit(0) & " " & cddts.Oral(0) & " " & cddts.Fac)
|
|
'Next
|
|
'FileClose(nf)
|
|
End Sub
|
|
|
|
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
|
|
ListBox1.Items.Clear()
|
|
|
|
|
|
Dim OpenFile As New OpenFileDialog
|
|
OpenFile.FileName = ""
|
|
OpenFile.Filter = "Fichier Candidate 7 Pro (*.C7P)|*.C7P"
|
|
OpenFile.Title = "Ouvrir une base de candidat C7P"
|
|
OpenFile.ShowDialog()
|
|
Try
|
|
Dim i As Integer = 0
|
|
nf = FreeFile()
|
|
'Dim Read As New System.IO.StreamReader(OpenFile.FileName)
|
|
FileOpen(nf, OpenFile.FileName, OpenMode.Random, OpenAccess.ReadWrite, OpenShare.Shared, lght)
|
|
FileGet(nf, cddts, 1)
|
|
NbPers = cddts.CP
|
|
Label1.Text = "Nombre de candidats : " & NbPers
|
|
For i = 1 To NbPers
|
|
FileGet(nf, cddts, i)
|
|
ListBox1.Items.Add(cddts.Nom & ", " & cddts.Prenom & ", " & cddts.Adresse & " " & cddts.CP & ", " & cddts.Ville & ", " & cddts.Age & ", (" & cddts.Ecrit(0) & "-" & cddts.Ecrit(1) & "-" & cddts.Ecrit(2) & "-" & cddts.Ecrit(3) & ") (" & cddts.Oral(0) & "-" & cddts.Oral(1) & "-" & cddts.Oral(2) & ") " & cddts.Fac)
|
|
Next
|
|
Catch ex As Exception
|
|
|
|
End Try
|
|
FileClose(nf)
|
|
End Sub
|
|
|
|
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
|
|
'Dim Savefile As New SaveFileDialog
|
|
'Savefile.FileName = ""
|
|
'Savefile.Filter = "Fichier texte (*.txt)|*.txt"
|
|
'Savefile.Title = "Sauvegarder en clair"
|
|
'Savefile.ShowDialog()
|
|
'Try
|
|
Dim i As Integer = 0
|
|
nf = FreeFile()
|
|
FileOpen(nf, "Liste.txt", OpenMode.Output, OpenAccess.Write, OpenShare.Shared)
|
|
For i = 0 To ListBox1.Items.Count - 1
|
|
FilePutObject(nf, ListBox1.Items.Item(i), i + 1)
|
|
Next
|
|
'Catch ex As Exception
|
|
' MsgBox("L'enregistrement a échoué.")
|
|
|
|
'End Try
|
|
'FileClose(nf)
|
|
End Sub
|
|
|
|
|
|
End Class
|