Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
This code snippet demonstrates two ways to extract...
Author:
Gilles Saunier-l'Hégaret
E-mail:
Click to e-mail author
Submitted:
2/19/2002
Version:
VB5
Compatibility:
VB5, VB6
Category:
String Manipulation
Views:
10618
This code snippet demonstrates two ways to extract a filename in a path.
Declarations:
'none
Code:
'-----------------(Get a filename in a path string) ' 2 command buttons (Command1, Command2) and Form1 'déclaration Dim FilePath$ '--------------------- '1st tip '------------------------------------------- Private Sub Command1_Click() Dim i%, grall$ For i = 1 To Len(FilePath) If Left(Right(FilePath, i), 1) = "\" Then grall = Right(FilePath, i - 1) Exit For End If Next i MsgBox grall,0+64,"Filename..." '--------------------------------------------- '2d tip (choose between speed and elegance...) '--------------------------------------------- Private Sub Command2_Click() Dim Ret$, Str0$, grall$ Dim i% ,pos% Str0 = FilePath Ret = "" For i = 1 To Len(FilePath) 'inverseStr Ret = Ret & Right(Str0, 1) Str0 = Left(FilePath, Len(FilePath) - i) Next i pos= InStr(1, Ret, "\") 'slash position in inverseStr MsgBox str(Right(FilePath,pos - 1)),0+64,"Filename..." ----------------------
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement