Results 1 to 8 of 8

Thread: Common dialog. .and listbox . also a new error

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2007
    Posts
    330

    Resolved Common dialog. .and listbox . also a new error

    ok theres a text.txt that countains somehting like this
    a word
    2nd word
    3rd word
    etc
    etc


    so when I open to listbox loads like this
    a word
    2nd word
    3rd word
    ....

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Common dialog. .and listbox D:

    Something like this should work for you:
    Code:
    Private Sub Command1_Click()
    Dim arItems() As String
    Dim sText As String
    Dim i As Integer
    
    On Error GoTo ErrHandler
    
        With CommonDialog1
            .FileName = ""
            .InitDir = "c:\"
            .Filter = "Text (*.txt)|*.txt"
            .CancelError = True
            .ShowOpen
            
            Open .FileName For Input As #1
                sText = Input(LOF(1), #1)
            Close #1
        End With
        
        arItems() = Split(sText, vbNewLine)
        For i = 0 To UBound(arItems)
            List1.AddItem arItems(i)
        Next i
        
        Exit Sub
        
    ErrHandler:
    
        Err.Clear
    
    End Sub

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2007
    Posts
    330

    Re: Common dialog. .and listbox D:

    It work'd .. thanks alot

  4. #4

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2007
    Posts
    330

    Re: [RESOLVED] Common dialog. .and listbox D:

    ..But still . the List I want to load in has around 70,000 lines.. and doesnt load , Is there a way to bypass that?

  6. #6
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Common dialog. .and listbox . also a new error

    Standard Listbox can only handle up to 32,767 (ListCount is Integer type) list items so you may need to substitute Listbox with ListView control.

    On a side note - why loading so many items - noone will scroll through that many anyway.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2007
    Posts
    330

    Re: Common dialog. .and listbox . also a new error

    ok , can you help me on listview to load a wordlist there now?

  8. #8

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