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
| Option Explicit
Dim T As Integer
Dim LeftText As Integer
Dim WidthText As Integer
Dim TopText As Integer
Dim MemoPict As Long
Dim wsExcel_Cells() As String
Dim U As Integer
Dim DecoupeContenuLg() As String
Dim DecoupeContenuCl() As String
Dim Msg$
Private Sub Form_Initialize()
Dim NumFich As Integer
NumFich = FreeFile
Open App.Path & "\LesDonnées.txt" For Input As #NumFich
Msg$ = Input(FileLen(App.Path & "\LesDonnées.txt"), NumFich)
Close #NumFich
'création du tableau ,indice Ligne (4)
DecoupeContenuLg = Split(Msg$, vbCrLf)
'création du tableau ,indice colonne (5)
DecoupeContenuCl = Split(DecoupeContenuLg(0), ",")
ReDim wsExcel_Cells(UBound(DecoupeContenuLg) - 1, UBound(DecoupeContenuCl) - 1)
Msg$ = DecoupeContenuCl(0)
Msg$ = DecoupeContenuLg(3)
For T = 0 To UBound(DecoupeContenuLg) - 1
DecoupeContenuCl = Split(DecoupeContenuLg(T), ",")
For U = 0 To UBound(DecoupeContenuCl) - 1
wsExcel_Cells(T, U) = DecoupeContenuCl(U)
Next U
Next T
End Sub
Private Sub Form_Load()
'defini le nombre de lignes et de colonnes
Dim NbrLgn As Integer
Dim NbrCln As Integer
NbrLgn = UBound(DecoupeContenuLg)
NbrCln = UBound(DecoupeContenuCl)
MSHFlexGrid1.Rows = NbrLgn + 1 'ajout de la ligne FIXE
MSHFlexGrid1.Cols = NbrCln + 1 'ajout de la colonne FIXE
MSHFlexGrid1.FixedCols = 1: MSHFlexGrid1.FixedRows = 1
'donne un titre a chaque colonne
MSHFlexGrid1.FormatString = " |Ville|Col1|Col2|N° Dep.|Dep."
MSHFlexGrid1.ColWidth(0) = 300
MSHFlexGrid1.ColWidth(1) = 1500
MSHFlexGrid1.ColWidth(2) = 400
MSHFlexGrid1.ColWidth(3) = 400
MSHFlexGrid1.ColWidth(4) = 300
MSHFlexGrid1.ColWidth(5) = 2000
'dimensionne le grid en largeur
MSHFlexGrid1.Width = 0
For T = 0 To MSHFlexGrid1.Cols - 1
MSHFlexGrid1.Width = MSHFlexGrid1.Width + MSHFlexGrid1.ColWidth(T)
Next T
'ajout du Scroling
MSHFlexGrid1.Width = MSHFlexGrid1.Width + 245
Me.Width = MSHFlexGrid1.Width + (MSHFlexGrid1.Left * 2) + 60
TextEntrer.Height = MSHFlexGrid1.RowHeight(1) - 15
TextEntrer.Left = -TextEntrer.Width
'rempli les cellules
For T = 0 To NbrLgn - 1
MSHFlexGrid1.Row = T + 1
MSHFlexGrid1.TextMatrix(T + 1, 1) = wsExcel_Cells(T, 0)
MSHFlexGrid1.Col = 2
If wsExcel_Cells(T, 1) = "TRUE" Then
Set MSHFlexGrid1.CellPicture = PictChecked.Image 'place une image
End If
MSHFlexGrid1.Col = 3
If wsExcel_Cells(T, 2) = "TRUE" Then
Set MSHFlexGrid1.CellPicture = PictChecked.Image 'place une image
End If
MSHFlexGrid1.TextMatrix(T + 1, 4) = wsExcel_Cells(T, 3)
MSHFlexGrid1.TextMatrix(T + 1, 5) = wsExcel_Cells(T, 4)
Next T
End Sub |