Results 1 to 7 of 7

Thread: Help!!!!

Hybrid View

  1. #1

    Thread Starter
    Lively Member Xero's Avatar
    Join Date
    Feb 2000
    Posts
    75

    Exclamation

    I if have a variable that contains a path of a file(Ex: "C:\New Folder\blah.ini") how can i take that and get rid of the path, making it just "blah.ini"?

    Any help is appreciated! Thank yoU!

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    Option Explicit
    
    Private Sub Command1_Click()
    ' A text comparison starting at #1 position looking for \
    
        Dim SearchString, SearchChar, MyPos
        SearchString = "C:\New Folder\blah.ini"  ' String to search in.
        SearchChar = "\"   ' Search for "\".
    
    Dim i As Integer
    For i = 1 To Len(SearchString)
        MyPos = InStr(1, SearchString, SearchChar, 1)
    
    'if found MyPos will be > 0
        If MyPos > 0 Then
            SearchString = Right(SearchString, Len(SearchString) - MyPos)
        End If
        
        Next i
        
       MsgBox SearchString
    
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3

    Thread Starter
    Lively Member Xero's Avatar
    Join Date
    Feb 2000
    Posts
    75
    I just found a much much simplier way:

    Code:
    #!/usr/bin/perl
    
    'in module
    
    Public Function FileName(FilePath as String)
        FileName = Left(FilePath, Len(FilePath) - InStrRev(FilePath, "\"))
    End Function
    That returns the filename, much simplier and faster. Thanks anyway!




    [Edited by Xero on 09-24-2000 at 06:38 PM]

  4. #4

    Thread Starter
    Lively Member Xero's Avatar
    Join Date
    Feb 2000
    Posts
    75
    nevermind, it doesnt work =).

  5. #5
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    tested it?
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  6. #6

    Thread Starter
    Lively Member Xero's Avatar
    Join Date
    Feb 2000
    Posts
    75
    Oh! To fix it replace Left with Right, silly me .

  7. #7
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    already did that...
    thanks...I'll add it to my mdb
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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