Results 1 to 5 of 5

Thread: Remove text from end of string

  1. #1

    Thread Starter
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772

    Remove text from end of string

    I have a page that lists all the files in the folder. How can I remove the extension from the string containing the file name? For example: file1.asp -> file1, somepage.html -> somepage, etc.
    Alcohol & calculus don't mix.
    Never drink & derive.

  2. #2
    CMangano
    Guest
    Well, without writing the code for you:

    1) get the file name in a variable.

    2) Loop through the file name until you find a "."

    3) Find out how many characters are after the "." So, for .asp it would be 3. For .html it would be 4.

    4) Do a replace on your variable, replacing the Right 4 characters of your variable with nothing.

    HTH

    BTW, what the heck is that picture you have under your name, and better yet, what the hell is he doing?

  3. #3
    PowerPoster sail3005's Avatar
    Join Date
    Oct 2000
    Location
    Chicago, IL, USA
    Posts
    2,340
    whatever it is doing, it looks painful!

    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA

  4. #4

    Thread Starter
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    Well, the program I got it from says he is "fidgeting."

    Alcohol & calculus don't mix.
    Never drink & derive.

  5. #5
    chenko
    Guest
    VB Code:
    1. Function StripEXT(FileName)
    2.   Dim SplitData
    3.   Dim i
    4.  
    5.   SplitData = Split(FileName, ".")
    6.  
    7.   For i = 0 to UBound(SplitData) - 1
    8.       If i = 0 Then
    9.            StripEXT= SplitData(i)
    10.       Else
    11.            StripEXT= StripEXT& "." & SplitData(i)
    12.       End If
    13.   Next
    14. End Function

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