Results 1 to 4 of 4

Thread: [RESOLVED] Show only part of a filename in a label vb6

  1. #1

    Thread Starter
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Resolved [RESOLVED] Show only part of a filename in a label vb6

    How do i get the last part of a filename after the last backslash and leave off the extension ?
    Typical file name:
    C:\Documents and Settings\All Users.WINDOWS\Documents\Real20CardKeno\KingKeno\SavedKingKenoGames\10 spot top row bet 10 cents.cle
    Example: What i need
    lblFilename = "10 spot top row bet 10 cents"
    this part could be any length
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  2. #2
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: Show only part of a filename in a label vb6

    Code:
    Public Function GetBaseName(ByRef Path As String) As String
        Dim StartPos As Long, EndPos As Long
    
        StartPos = InStrRev(Path, "\") + 1&
        EndPos = InStrRev(Path, ".")
        GetBaseName = Mid$(Path, StartPos, EndPos - StartPos)
    End Function
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  3. #3

    Thread Starter
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Re: Show only part of a filename in a label vb6

    Quote Originally Posted by Bonnie West View Post
    Code:
    Public Function GetBaseName(ByRef Path As String) As String
        Dim StartPos As Long, EndPos As Long
    
        StartPos = InStrRev(Path, "\") + 1&
        EndPos = InStrRev(Path, ".")
        GetBaseName = Mid$(Path, StartPos, EndPos - StartPos)
    End Function
    Just what i needed thanks
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  4. #4

    Thread Starter
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Re: Show only part of a filename in a label vb6

    Quote Originally Posted by Bonnie West View Post
    Code:
    Public Function GetBaseName(ByRef Path As String) As String
        Dim StartPos As Long, EndPos As Long
    
        StartPos = InStrRev(Path, "\") + 1&
        EndPos = InStrRev(Path, ".")
        GetBaseName = Mid$(Path, StartPos, EndPos - StartPos)
    End Function
    You must spread some Reputation around before giving it to Bonnie West again.
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

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