Results 1 to 12 of 12

Thread: Why won't this work?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624

    Why won't this work?

    VB Code:
    1. Private Sub Drive1_Change()
    2. Dim x As Integer
    3. Dim fname As String
    4.  
    5. If Drive1.Drive = "c:" Then
    6.     File1.Path = "c:\Mp3s"
    7. Else
    8. File1.Path = "d:\mp3s"
    9. End If
    10.  
    11.    
    12.     For x = 0 To File1.ListCount - 1
    13.         fname = File1.Path & "\" & File1.List(x)
    14.        
    15.         Set i = ListView1.ListItems.Add(, , File1.List(x))
    16.         i.SubItems(1) = File1.Path
    17.     DoEvents
    18.    
    19.     Next
    20. End If
    21.  
    22. End Sub

  2. #2
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344
    What are you trying to do?
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  3. #3
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    what do you mean by "Why won't this work"? What exactly is not working?
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624

    ok...

    When the user changes the drive letter in the drivelistbox, it checks to see which drive is selected. Then, it sets the filelistbox path based on which drive is selected, and adds all of the files and their paths to the listview

  5. #5
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: ok...

    Originally posted by hipopony66
    When the user changes the drive letter in the drivelistbox, it checks to see which drive is selected. Then, it sets the filelistbox path based on which drive is selected, and adds all of the files and their paths to the listview
    Is that for the folder that the user chooses?
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  6. #6
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    Try:
    VB Code:
    1. i.ListSubItems.Add , , File1.Path

  7. #7
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    And I think that last End IF should go.

  8. #8
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    hipopony66,

    In any event I think u have a few things back-to-front.

    I'm just trying to sort them out now

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624

    Ok, here's problem

    It never finds the drive1.drive ="c:\"

    Even though the C: drive is selected. What could cause this?

    does the drive label have to be included? and if so, how come you can set the default drive by putting in form load event

    drive1.drive= "d:\"?

  10. #10
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    Here u go:
    VB Code:
    1. Private Sub Drive1_Change()
    2.     Dim fname As String
    3.     Dim x As Integer
    4.  
    5.     If Left$(Drive1.Drive, 2) = "c:" Then  'Change here
    6.         File1.Path = "c:\Mp3s"
    7.     Else
    8.         File1.Path = "d:\Mp3s"
    9.     End If
    10.  
    11.     With ListView1    'Added this
    12.         .ColumnHeaders.Clear
    13.         .View = lvwReport
    14.         .ColumnHeaders.Add , , "Path", 1000, 0
    15.         .ColumnHeaders.Add , , "Song Title", 2000, 0
    16.     End With
    17.  
    18.     For x = 0 To File1.ListCount - 1    'Changes made here
    19.         fname = File1.Path & "\" & File1.List(x)
    20.         Set i = ListView1.ListItems.Add(, , fname)
    21.         i.ListSubItems.Add , , File1.List(x)
    22.     Next
    23.  
    24. End Sub

    The C: wasn't found cause .Drive = "C: [Drive Name]"

  11. #11
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    This here seems to work...

    VB Code:
    1. Private Sub Drive1_Change()
    2. Dim x As Integer
    3. Dim fname As String
    4.  
    5. If Drive1.Drive = "c:" Then
    6.     File1.Path = "c:\Mp3's"
    7.  
    8. Else
    9. File1.Path = "d:\mp3s"
    10. End If
    11. For x = 0 To File1.ListCount - 1
    12.       Label1 = File1.Path & "\" & File1.List(x)
    13.        
    14.         Set i = ListView1.ListItems.Add(, , File1.List(x))
    15.     Next
    16. End Sub
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  12. #12
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    After a few slight changes, ie fname isn't required.
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Drive1_Change()
    4.     Dim x As Integer
    5.     Dim i As ListItem    'Added this
    6.  
    7.     If Left$(Drive1.Drive, 2) = "c:" Then  'Change here
    8.         File1.Path = "c:"
    9.     Else
    10.         File1.Path = "d:"
    11.     End If
    12.  
    13.     With ListView1    'Added this
    14.         .ColumnHeaders.Clear
    15.         .View = lvwReport
    16.         .ColumnHeaders.Add , , "Path", 1000, 0
    17.         .ColumnHeaders.Add , , "Song Title", 2000, 0
    18.     End With
    19.  
    20.     For x = 0 To File1.ListCount - 1    'Changes made here
    21.         Set i = ListView1.ListItems.Add(, , File1.Path) 'Replaced fname
    22.         i.ListSubItems.Add , , File1.List(x)
    23.     Next
    24.  
    25. 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