Crop a string at a certain character

djlysuc

Registered User.
Local time
Today, 16:46
Joined
May 22, 2006
Messages
11
Hi,

Im looking for a way to remove the file name from a string to use the ChDir statement in vb??

convert:
C:\dir1\dir2\myfile.exe

to:
C:\dir1\dir2

Any help will be appreciated. Thanks.
 
Last edited:
Hello:
Use the following statement:
y = Left$(Text0, InStrRev(Text0, "\") - 1)
'
If you had a text box named Text0 on your form with your "C:\dir1\dir2\myfile.exe" string in it, the above would extract "C:\dir1\dir2"
'
Regards
Mark
 
Thanks Mark. It must be Monday, I didn't think of doing it that way.
 

Users who are viewing this thread

Back
Top Bottom