Results 1 to 3 of 3

Thread: easy? using dirlistbox

  1. #1

    Thread Starter
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Smile

    Hi everyone, susspected easy one this.

    I am doing a backup app. the user selects a drive from the dirlistbox function, & the resulting directory is put into a text box (which changes with the dirlistbox option selected).

    Right, I noticed then, that the textbox does not show a "\" after the text, ie c and not C\.I am using the fso.copyfile method & need that \ in, so Ok I wrote :

    TxtBox1.text = Dir1.path & "\" on the dirlistbos click event.

    My question, after all of that, is because I get C\\ if the user selects a drive & not a folder. Instead of a very long if-then statement to go through drives a-z, is there another way I can just put in the \ if it's a folder & not a drive?

    (Hope I made sense there)
    Thank you,
    Alex Read

    VB6 Learning Edition & SP4


  2. #2
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    Use something like this:


    Code:
    Function NormalisePath(strPath As String) As String
    
    If Right(strPath, 1) = "\" Then
      NormalisePath = strPath
    Else
      NormalisePath = strPath & "\"
    End If
    
    
    End Function
    Mark
    -------------------

  3. #3

    Thread Starter
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    EXCELLENT

    Cannot thank you enough for that, I dread to think of the time if would have taken me otherwise,

    If txt <> "A:\"

    If txt <> "B:\"

    Etc upto Z!

    You have been a great help, and responded very quickly, thank you!

    Alex Read

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