|
-
Jun 27th, 2001, 09:58 AM
#1
Thread Starter
Lively Member
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."
-
Jun 27th, 2001, 10:02 AM
#2
try this
VB Code:
Left("blah.txt", InStrRev("blah.txt", ".") -1)
-
Jun 27th, 2001, 10:02 AM
#3
_______
<?>
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
-
Jun 27th, 2001, 10:03 AM
#4
Hyperactive Member
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
-
Jun 27th, 2001, 10:14 AM
#5
_______
<?>
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
-
Jun 27th, 2001, 10:17 AM
#6
Hyperactive Member
That is correct...
Darn long file names...
I'm still stuck in an 8.3 world :-)
-
Jun 27th, 2001, 10:18 AM
#7
Thread Starter
Lively Member
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."
-
Jun 27th, 2001, 10:42 AM
#8
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|