+ Reply to Thread
Results 1 to 3 of 3

sorting collection by 'NumerPozycji' with 2 classes

  1. #1
    Registered User
    Join Date
    05-13-2013
    Location
    Poland
    MS-Off Ver
    Excel 2003
    Posts
    1

    sorting collection by 'NumerPozycji' with 2 classes

    Modulo: Module1
    ' I would like to sort collection by 'NumerPozycji'.

    ' 'NumerPozycji' is a property of a classes

    Option Explicit
    Dim kolekcjaBlachyIprofile As Collection
    Dim blacha02S As BlachyAll, blacha03S As BlachyAll, blacha04S As BlachyAll, blacha05S As BlachyAll
    Dim blacha06S As BlachyAll, blacha07S As BlachyAll, blacha08S As BlachyAll
    Dim profilSlup As ProfileAll

    Sub slup10()
    Set kolekcjaBlachyIprofile = New Collection

    Set blacha02S = New BlachyAll
    blacha02S.NumerPozycji = 4
    blacha02S.Grubosc = 5
    blacha02S.Szerokosc = 120
    blacha02S.Dlugosc = 850
    blacha02S.LiczbaSztuk = 1
    kolekcjaBlachyIprofile.Add blacha02S

    Set blacha03S = New BlachyAll
    blacha03S.NumerPozycji = 3
    blacha03S.Grubosc = 9
    blacha03S.Szerokosc = 48
    blacha03S.Dlugosc = 320
    blacha03S.LiczbaSztuk = 1
    kolekcjaBlachyIprofile.Add blacha03S

    Set blacha04S = New BlachyAll
    blacha04S.NumerPozycji = 2
    blacha04S.Grubosc = 12
    blacha04S.Szerokosc = 56
    blacha04S.Dlugosc = 320
    blacha04S.LiczbaSztuk = 2
    kolekcjaBlachyIprofile.Add blacha04S

    Set blacha05S = New BlachyAll
    blacha05S.NumerPozycji = 5
    blacha05S.Grubosc = 16
    blacha05S.Szerokosc = 80
    blacha05S.Dlugosc = 220
    blacha05S.LiczbaSztuk = 5
    kolekcjaBlachyIprofile.Add blacha05S

    Set blacha06S = New BlachyAll
    blacha06S.NumerPozycji = 7
    blacha06S.Grubosc = 20
    blacha06S.Szerokosc = 240
    blacha06S.Dlugosc = 500
    blacha06S.LiczbaSztuk = 1
    kolekcjaBlachyIprofile.Add blacha06S

    Set blacha07S = New BlachyAll
    blacha07S.NumerPozycji = 6
    blacha07S.Grubosc = 25
    blacha07S.Szerokosc = 120
    blacha07S.Dlugosc = 260
    blacha07S.LiczbaSztuk = 2
    blacha07S.SzerokoscD = 80
    kolekcjaBlachyIprofile.Add blacha07S

    Set blacha08S = New BlachyAll
    blacha08S.NumerPozycji = 8
    blacha08S.Grubosc = 10
    blacha08S.Szerokosc = 80
    blacha08S.Dlugosc = 80
    blacha08S.LiczbaSztuk = 2
    kolekcjaBlachyIprofile.Add blacha08S

    Set profilSlup = New ProfileAll
    profilSlup.NumerPozycji = 1
    profilSlup.Nazwa = "HEB260"
    profilSlup.LiczbaSztuk = 2
    profilSlup.Masa = 35.6
    profilSlup.Dlugosc = 4532
    kolekcjaBlachyIprofile.Add profilSlup
    End Sub

    Class: BlachyAll
    Option Explicit

    Public Nazwa As String
    Public Masa As Double

    Public Grubosc As Double
    Public Szerokosc As Double
    Public SzerokoscD As Double
    Public Dlugosc As Double

    Public LiczbaSztuk As Integer
    Public NumerPozycji As Integer

    Const WspolczynnikMasy = 7850

    class: ProfileAll
    Public Nazwa As String
    Public Masa As Double
    Public Dlugosc As Double

    Public LiczbaSztuk As Integer
    Public NumerPozycji As Integer

  2. #2
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: sorting collection by 'NumerPozycji' with 2 classes

    This will help with sorting a collection: http://www.cpearson.com/excel/Collec...ctionaries.htm
    and you'll have to adapt it to sort by the integer class property NumerPozycji.

    Good luck
    Please use [CODE]-TAGS
    When your problem is solved mark the thread SOLVED
    If an answer has helped you please click to give reputation
    Read the FORUM RULES

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: sorting collection by 'NumerPozycji' with 2 classes

    Why not just rearrange the code to add them in the preferred order?
    Entia non sunt multiplicanda sine necessitate

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1