Results 1 to 8 of 8

Thread: need to seperate string by .

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2001
    Location
    CT
    Posts
    124

    need to seperate string by .

    I'm loading a file name into a string and would like to cut off the file extension .txt, .exe, etc.. so it's only left with the name of the file.

    What would I use,

    I just learned the great use of left$, Mid$, Right$ yesterday but out of all of those the Right$ would be closest to what I need and 'say remove the last 4 characters instead of use them' but, that's not working,
    Vini, Vidi, Vici!
    -----------------
    say this 5 times fast
    "I am not a pheasant plucker, I'm a pheasant plucker's son. I'm only plucking pheasants, till the pheasant plucker comes."

  2. #2
    nullus
    Guest
    try this

    VB Code:
    1. Left("blah.txt", InStrRev("blah.txt", ".") -1)

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

    <?>

    MsgBox Mid(sFileName, InStrRev(sFileName, "\") + 1)
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  4. #4
    Hyperactive Member rockies1's Avatar
    Join Date
    Jul 1999
    Location
    Stuck at work
    Posts
    375

    Talking

    How about something like this:
    Code:
    Dim strFileName As String
    Dim strNewName As String
    strFileName = "This is my file.txt"
    strNewName = Left(strFileName, Len(strFileName) - 4)
    MsgBox strNewName
    Morgan
    [email protected] - Home
    [email protected] - Work
    Using VB6 SP6 but trying to learn VB2005EE

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

    <?>

    rockies1

    that would work for 3 letter extensions only.
    .html would give you grief.
    "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
    Hyperactive Member rockies1's Avatar
    Join Date
    Jul 1999
    Location
    Stuck at work
    Posts
    375
    That is correct...

    Darn long file names...

    I'm still stuck in an 8.3 world :-)
    Morgan
    [email protected] - Home
    [email protected] - Work
    Using VB6 SP6 but trying to learn VB2005EE

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Jun 2001
    Location
    CT
    Posts
    124
    wow, two different ways that look good, great.

    strNewName = Left(strFileName, Len(strFileName) - 4)
    (couldn't get to work)


    Left("blah.txt", InStrRev("blah.txt", ".") -1)
    (yea)
    Vini, Vidi, Vici!
    -----------------
    say this 5 times fast
    "I am not a pheasant plucker, I'm a pheasant plucker's son. I'm only plucking pheasants, till the pheasant plucker comes."

  8. #8
    nullus
    Guest
    wuhoo! i'm on a roll

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