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
| Option Explicit
Private Sub Form_Activate()
Picture1.AutoRedraw = True
Dim nbcol As Integer, nblignes As Integer, coefx As Single, coefy As Single
Dim haut As Integer, larg As Integer, corrx As Integer, corry As Integer
'==========================================================================================
'C'est ici que vous définissez votre tableau et son affichage
'IMPORTANT : nbcol * nblignes DOIT BIEN EVIDEMMENT ETRE SUPERIEUR AU NOMBRE DE CASES D'AFFICHAGE
nbcol = 7 ' on inscrit ici le nombre de colonnes
nblignes = 5 'on inscrit ici le nombre de lignes
coefx = 0.5 ' on choit ici un coefficient d'occupation de la largeur d'une case
coefy = 0.6 ' on choit ici un coefficient d'occupation de la hauteur d'une case
'===========================================================================================
haut = Int(Picture1.Height / nblignes) * coefy
larg = Int(Picture1.Width / nbcol) * coefx
corrx = (Int(Picture1.Width / nbcol) - larg) / 2
corry = (Int(Picture1.Height / nblignes) - haut) / 2
Dim nb As Integer, i As Integer, j As Integer
nb = 0
For i = 0 To Picture1.Width Step Int(Picture1.Width / nbcol)
Picture1.Line (i, 0)-(i, Picture1.Height)
On Error Resume Next
For j = 0 To nbcol
Text1(nb + (j * nbcol)).Move i + corrx, Text1(nb + (j * nbcol)).Top, larg, haut * coefy
'=================================================================================
'la ligne qui suit n'est là que pour permettre d'étiquetter et voir la répartition
Text1(nb + (j * nbcol)).Text = nb + (j * nbcol)
'================================================================================
Next j
nb = nb + 1
If nb >= nbcol Then Exit For
Next
nb = 0
For i = 0 To Picture1.Height Step Int(Picture1.Height / nblignes)
Picture1.Line (0, i)-(Picture1.Width, i)
On Error Resume Next
For j = 0 To nbcol
Text1(nb * nbcol + j).Top = i + corry
Next j
nb = nb + 1
If nb >= nblignes Then Exit For
Next
End Sub |
Partager