VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Creates a Buttons Matrix at Run Time (Just specified the number of buttons and the size of the matr

by Tiago Jorge (1 Submission)
Category: Custom Controls/Forms/Menus
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 18th April 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Creates a Buttons Matrix at Run Time (Just specified the number of buttons and the size of the matrix) and the Form will adjust to the size of

API Declarations



Const Comps = 45
Const Matrix = 8 'Columns
Const ButtonHeigth = 1000
Const ButtonWidth = 1455

Rate Creates a Buttons Matrix at Run Time (Just specified the number of buttons and the size of the matr



    MsgBox "CPU: " & Index + 1, vbInformation, "CPU"
End Sub

Sub FormSize()
Dim Lines, Columns
    'Form Heigth
    If Comps Mod Matrix <> 0 Then
        Lines = Int(Comps / Matrix) + 1
    Else
        Lines = Comps / Matrix
    End If
    'Form Width
    If Matrix > Comps Then
        Columns = Comps
    Else
        Columns = Matrix
    End If
    Me.Height = (ButtonHeigth * Lines) + 380      'Lines (n Buttons + Title)
    Me.Width = (ButtonWidth * Columns) + 95        'Columns (m Buttons + Form)
End Sub

Private Sub Form_Load()
Dim i
    FormSize
    'First Button
    Command1(0).Top = 0
    Command1(0).Left = 0
    Command1(0).Width = ButtonWidth
    Command1(0).Height = ButtonHeigth
    Command1(0).Caption = "CPU 1"
    'Next Buttons
    For i = 1 To Comps - 1
        Load Command1(i)
        Command1(i).Caption = "CPU " & i + 1
        Command1(i).Visible = True
        Command1(i).Left = Command1(i - 1).Left + ButtonWidth
        Command1(i).Top = Command1(i - 1).Top
        
        If i Mod Matrix = 0 Then
            Command1(i).Left = 0
            Command1(i).Top = ButtonHeigth * Int(i / Matrix)
        End If
    Next i
End Sub


Download this snippet    Add to My Saved Code

Creates a Buttons Matrix at Run Time (Just specified the number of buttons and the size of the matr Comments

No comments have been posted about Creates a Buttons Matrix at Run Time (Just specified the number of buttons and the size of the matr. Why not be the first to post a comment about Creates a Buttons Matrix at Run Time (Just specified the number of buttons and the size of the matr.

Post your comment

Subject:
Message:
0/1000 characters