Results 1 to 6 of 6

Thread: How to get array values in ascending order.

  1. #1

    Thread Starter
    Addicted Member thiru_rajamani's Avatar
    Join Date
    Aug 2004
    Location
    Chennai,India
    Posts
    214

    Question How to get array values in ascending order.

    Dear all ,
    I have written the following program which is used to calculate the number of components and their names in an assembly file (solidworks, 3d modelling). But the array used in this program does not give values in ascending order. How to get a array values in ascending order.

    For ex : a list box contains "n" No. of valuse, I need to extract all the values in ascending order, as it is listed in the list box.

    How to get a array values in ascending order. ?

    Regards
    rajamaniThiruvengadam

    Sub main()
    Dim swApp As Object
    Dim SWConfig As SldWorks.Configuration
    Dim SWRootComp As SldWorks.component
    Dim Children As Variant
    Dim SWChild As SldWorks.component
    Dim ChildCount As Integer
    Dim bOldSetting As Boolean
    Dim bRet As Boolean
    Dim SWModel As SldWorks.ModelDoc2

    Set swApp = Application.SldWorks
    Set SWModel = swApp.ActiveDoc
    Set SWConfig = SWModel.GetActiveConfiguration
    Set SWRootComp = SWConfig.GetRootComponent
    Children = SWRootComp.GetChildren
    ChildCount = UBound(Children)
    'Debug.Print SWRootComp.Name
    Debug.Print ChildCount
    For i = 0 To ChildCount
    Set SWChild = Children(i)

    'SwCmp1InsNam = swChild.Name2
    'SwCmp1InsNam1 = swChild.Name2
    Debug.Print i
    Debug.Print SWChild.Name
    Next i
    End Sub

    =======================
    Actual order

    Sub_Assy_1-1
    Sub_Assy_2-3
    Sub_Assy_3-4
    Wrong_Planes_1-3
    Wrong_Planes_2-3
    =======================

    Result I am getting is

    0
    Sub_Assy_2-3
    1
    Sub_Assy_3-4
    2
    Wrong_Planes_1-3
    3
    Sub_Assy_1-1
    4
    Wrong_Planes_2-3
    Thanks
    Raj

  2. #2
    PowerPoster Deepak Sakpal's Avatar
    Join Date
    Mar 2002
    Location
    Mumbai, India
    Posts
    2,424

    just a suggestion

    why don't u add values to a sorted listbox and get it back.

  3. #3

    Thread Starter
    Addicted Member thiru_rajamani's Avatar
    Join Date
    Aug 2004
    Location
    Chennai,India
    Posts
    214

    What is sorted list box ?

    What is sorted list box ?
    Thanks
    Raj

  4. #4
    PowerPoster Deepak Sakpal's Avatar
    Join Date
    Mar 2002
    Location
    Mumbai, India
    Posts
    2,424
    drop a ListBox Control on form and set its Sorted property to True.

  5. #5

    Thread Starter
    Addicted Member thiru_rajamani's Avatar
    Join Date
    Aug 2004
    Location
    Chennai,India
    Posts
    214

    Resolved

    Thank you deepak, Ithe problem is solved
    Thanks
    Raj

  6. #6
    PowerPoster Deepak Sakpal's Avatar
    Join Date
    Mar 2002
    Location
    Mumbai, India
    Posts
    2,424
    u r welcome dude . put that green arrow in ur first post of this thread.

Posting Permissions

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



Click Here to Expand Forum to Full Width