Community
I am wondering if there is a way to use iLogic in:
1. searching the "N:\14projects" directory for a folder that contains "1499PAS"
2. return the string after the "-" i.e. "blah blah blah" see image below
Solved! Go to Solution.
Solved by LukeDavenport. Go to Solution.
Hi PhilShields. I think this will work:
As you specified - the code will give you everything after the '-' in the folder name. If you've got multiple '-' characters in the folder name then it'll find the first one and give you everything after that. Makes sense?
Imports System.IO Imports System.IO.File Dim EndOfFolderName As String
Dim StartOfFolderName As String = "1499PAS" Dim DirName As String
' Loop through all folders in the defined directory For Each dir As String In Directory.GetDirectories("N:\14projects")
Dim dirInfo As New DirectoryInfo(Dir) DirName = dirInfo.Name ' Check to see if the folder name starts with the defined text
If DirName.Contains(StartOfFolderName) Then ' Create a string containing folder name after the character '-'
EndOfFolderName = Right(DirName, Len(DirName) - DirName.IndexOf("-") - 2) MessageBox.Show(EndOfFolderName, "Title") End If Next