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.
Printable View
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.
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?
whatever it is doing, it looks painful! :eek: :eek: :eek:
Well, the program I got it from says he is "fidgeting."
:eek:
VB Code:
Function StripEXT(FileName) Dim SplitData Dim i SplitData = Split(FileName, ".") For i = 0 to UBound(SplitData) - 1 If i = 0 Then StripEXT= SplitData(i) Else StripEXT= StripEXT& "." & SplitData(i) End If Next End Function