Results 1 to 2 of 2

Thread: List box help

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2006
    Posts
    91

    List box help

    I want to divide a the contents of a listbox into 2 different categories based on the length of the entries

    i want all of the entries with more than 5 characters inputted into another listbox, and i want the entries with less than 5 characters to be inputted into a different listbox.

    how would i go about this?

    thanks

  2. #2
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: List box help

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4.     List2.Clear: List3.Clear
    5.  
    6.     Dim N As Long
    7.         For N = 0 To List1.ListCount - 1
    8.             If Len(List1.List(N)) > 5 Then
    9.                 List2.AddItem List1.List(N)
    10.             Else
    11.                 List3.AddItem List1.List(N)
    12.             End If
    13.         Next N
    14. End Sub

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