vb6 common dialog box

Discussion in 'Software' started by mastermosley, Jul 18, 2007.

  1. mastermosley

    mastermosley Sergeant

    I'm using the box to locate files that are used within the program. It locates the files fine and when i make the textbox show the FileName like this:

    txtLoc(Index).Text = cmnDialog.Filename

    it works but it shows the C:\Documents and Settings\Owner\Desktop\Program\Misc\text.txt all that. I want the app.path part to be gone so all that all that it shows in the text is \Misc\text.txt

    Thanks.
     
  2. matt.chugg

    matt.chugg MajorGeek

    Many ways of doing this, assuming the commondialog doesn't have a built in way, one way would be to split the full path into an array of parts and check the last one.

    something like this:

    Code:
    Private Function FileNameFromFullPath(ByVal FullPath As String) As String
        If UBound(Split(FullPath, "\")) > 0 Then
            FileNameFromFullPath = Split(FullPath, "\")(UBound(Split(FullPath, "\")))
        Else
            FileNameFromFullPath = FullPath
        End If
    End Function
    
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds