FirasSHhady
Programmer
In the Form code window:
------------------------
Private Sub cmd_Click()
For Each Control In Me.Controls
If Control.Name = "Lbl" Then Call Alignlbl(Control, 30)
Next
End Sub
Private Sub Form_Load()
With Form1
.Width = 7000
.Top = 100
.Height = 8000
End With
End Sub
======================================================
In the Module Window:
---------------------
Sub Alignlbl(ByVal lbl As Label, N As Integer)
Dim I As Integer
For I = 1 To N
'Creat the control
Load lbl(I)
'Position of new controls
With lbl
.Left = lbl(I - 1)
.Top = lbl(I - 1).Top + lbl(I - 1).Height + 30
.Caption = I
'Make a different Backcolor
If I Mod 2 = 0 Then
.BackColor = &HC0FFFF
Else
.BackColor = &HC0FFC0
End If
'Width of new controls
Do While .Width < 0.5 * (Me.ScaleWidth)
.Width = .Width + 1
DoEvents
Loop
'Make them all visible
.Visible = True
End With
Next
End Sub
------------------------
Private Sub cmd_Click()
For Each Control In Me.Controls
If Control.Name = "Lbl" Then Call Alignlbl(Control, 30)
Next
End Sub
Private Sub Form_Load()
With Form1
.Width = 7000
.Top = 100
.Height = 8000
End With
End Sub
======================================================
In the Module Window:
---------------------
Sub Alignlbl(ByVal lbl As Label, N As Integer)
Dim I As Integer
For I = 1 To N
'Creat the control
Load lbl(I)
'Position of new controls
With lbl
.Left = lbl(I - 1)
.Top = lbl(I - 1).Top + lbl(I - 1).Height + 30
.Caption = I
'Make a different Backcolor
If I Mod 2 = 0 Then
.BackColor = &HC0FFFF
Else
.BackColor = &HC0FFC0
End If
'Width of new controls
Do While .Width < 0.5 * (Me.ScaleWidth)
.Width = .Width + 1
DoEvents
Loop
'Make them all visible
.Visible = True
End With
Next
End Sub