Results 1 to 5 of 5

Thread: Help with List Boxes

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    5

    Exclamation

    I have a List Box(List1) and in the properties area the Style is set to 1- Checkbox.

    The problem is that I have to check certain items in the check box based on a seperate file that looks something like this:

    #TRUE#
    #FALSE#
    #FALSE#
    #FALSE#
    #FALSE#
    #TRUE#
    #FALSE#

    The thing is that I have to do this in a list box with about 52 items in it. When the program is started I have to read from a .txt file that when veiwed looks like my original post. I have to read through the file and put a check in the list box next to every one that is True.

  2. #2
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    Try this:
    Code:
    Dim blnValue as Boolean
    Open "MyFile" for Input As #1
    Do Until EOF(1)
        Input #1, blnValue
        List1.AddItem CStr(blnValue)
        List1.Selected(List1.NewIndex) = blnValue
    Loop
    "It's cold gin time again ..."

    Check out my website here.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    5
    That almost worked. My problem is that My list box is already populated before I ever even read in the file. I have to put check marks next to items already in the list box without adding any new items. My list box contains each of the 50 States. Thanks for the help so far, I am one step closer.

  4. #4
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    As you loop thru a listbox, to check a particular item, do something like this:

    Code:
    For X = 0 To List1.ListCount - 1
        If List1.List(X) = "NJ" Or List1.List(X) = "PA" _
        Or (whatever) then
            List1.Selected(X) = True
        End If
    Next
    "It's cold gin time again ..."

    Check out my website here.

  5. #5

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    5
    Thanks for the help. It worked.

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