Results 1 to 14 of 14

Thread: [RESOLVED] Having trouble with Listbox

Threaded View

  1. #11
    Fanatic Member FireXtol's Avatar
    Join Date
    Apr 2010
    Posts
    874

    Re: Having trouble with Listbox

    I'd suggest Inet. Goto Components | Controls and check: Microsoft Internet Transfer Control

    Add the control to a form and add some code:
    vb Code:
    1. Dim strDirs As String
    2. strDirs = Inet1.OpenURL(YOUR_URL_HERE)

    Most likely your server will return a list of links. You can use StrFindBetween, for instance, see the link in my sig under Strings. You'll want to find: "<a href=""" to """>", then perform an Instr on the string between those two strings. In the Instr determine if there's a forward slash "/", and if so treat that as a directory, and not a file. If it's a file(and not a directory), then instr for the ".MP3" extension, and if so add it to the list.

    Now, add a List1, and try this:

    vb Code:
    1. Dim strDirs As String, strResult As String
    2. Dim X As Long, Y As Long
    3.  
    4. strDirs = Inet1.OpenURL("some_url_here")
    5.  
    6. X = InStr(strDirs, "<a href=""")
    7. Do While X > 0
    8.   X = X + Len("<a href=""")
    9.   Y = InStr(X, strDirs, """>")
    10.   If X And Y Then
    11.     strResult = LCase$(Mid$(strDirs, X, Y - X))
    12.     If InStr(strResult, "/") Then
    13.       'directory
    14.     ElseIf InStr(strResult, ".mp3") Then
    15.       'mp3 file
    16.       List1.AddItem Mid$(strDirs, X, Y - X) 'names are case sensitive, so re-fetch this
    17.     Else
    18.       'other file
    19.     End If
    20.   Else
    21.     Exit Do 'we're out of string, there are no matches
    22.   End If
    23.   X = InStr(Y, strDirs, "<a href=""")
    24. Loop

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