|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
enumeration help neededfolders. Base folder is D:\TestStuff\ Subfolders in that are Jones, Smith, Ryan (there could be several more and will not be named this simple) I want to run a loop that goes through those folders one at a time like this: For x = Jones to Ryan .... check for files in each sub folder and do a bunch of processing Next x I thought I could do soemthing with enumerations where the enum would be defined like this: Private enum clientFolders Jones = 1 Smith = 2 Ryan = 3 End Enum Then I could do something like this For x = 1 to 3 msgbox(clientFolders.x) next x But that doens't work. I'm not sure how to do this. Thanks, Keith I think I figured this out. Seems kind of convoluted but it works.
Private Enum clientName Jones Smith Ryan End Enum Dim clientFolderName As Type = GetType(clientName) Dim x As String For Each x In [Enum].GetNames(clientFolderName) MsgBox(x) Next Show quoteHide quote "Keith G Hicks" <k**@comcast.net> wrote in message news:uFHfC4a$KHA.1700@TK2MSFTNGP02.phx.gbl... >I want to run through an enumeration in a loop for scanning client sub >folders. > > Base folder is D:\TestStuff\ > > Subfolders in that are Jones, Smith, Ryan (there could be several more and > will not be named this simple) > > I want to run a loop that goes through those folders one at a time like > this: > > For x = Jones to Ryan > .... check for files in each sub folder and do a bunch of processing > Next x > > I thought I could do soemthing with enumerations where the enum would be > defined like this: > > Private enum clientFolders > Jones = 1 > Smith = 2 > Ryan = 3 > End Enum > > Then I could do something like this > > For x = 1 to 3 > msgbox(clientFolders.x) > next x > > > But that doens't work. I'm not sure how to do this. > > Thanks, > > Keith > Hi,
What is the benefit of using an enum for this when you'll use the names and not their underlying value ? You could enumerate folders below the root folder. If you really need to process only known folders under the root my personal preference would be likely to use an array... Dim SubFolders()={"Jones","Smith","Ryan"} For Each SubFolder As String In SubFolders ' Do stuff... Next -- Patrice
Show quote
Hide quote
On May 27, 10:13 am, "Keith G Hicks" <k***@comcast.net> wrote: In addition to Patrice's comments, what will you do when you decide to> I think I figured this out. Seems kind of convoluted but it works. > > Private Enum clientName > Jones > Smith > Ryan > End Enum > > Dim clientFolderName As Type = GetType(clientName) > Dim x As String > For Each x In [Enum].GetNames(clientFolderName) > MsgBox(x) > Next > > "Keith G Hicks" <k***@comcast.net> wrote in messagenews:uFHfC4a$KHA.1***@TK2MSFTNGP02.phx.gbl... > > >I want to run through an enumeration in a loop for scanning client sub > >folders. > > > Base folder is D:\TestStuff\ > > > Subfolders in that are Jones, Smith, Ryan (there could be several more and > > will not be named this simple) > > > I want to run a loop that goes through those folders one at a time like > > this: > > > For x = Jones to Ryan > > .... check for files in each sub folder and do a bunch of processing > > Next x > > > I thought I could do soemthing with enumerations where the enum would be > > defined like this: > > > Private enum clientFolders > > Jones = 1 > > Smith = 2 > > Ryan = 3 > > End Enum > > > Then I could do something like this > > > For x = 1 to 3 > > msgbox(clientFolders.x) > > next x > > > But that doens't work. I'm not sure how to do this. > > > Thanks, > > > Keith add another user in the future? Are you going to change your code every time? You might be better off using the System.IO.Directory.GetDirectories method to get the list of directories in the d:\teststuff folder: Dim clientFolders() As String = System.IO.Directory.GetDirectories("c: \teststuff") For Each folder As String in clientFolders 'Do stuff with folder here Next This code will work, even if you add more folders to c:\teststuff.
Show quote
Hide quote
"Chris Dunaway" <dunaw***@gmail.com> wrote in message Yes. I am. First, they're not users, they're clients. Second, the code is news:5a43ac1b-963c-4b91-8fa5-94d83545b878@o15g2000vbb.googlegroups.com... On May 27, 10:13 am, "Keith G Hicks" <k***@comcast.net> wrote: > I think I figured this out. Seems kind of convoluted but it works. > > Private Enum clientName > Jones > Smith > Ryan > End Enum > > Dim clientFolderName As Type = GetType(clientName) > Dim x As String > For Each x In [Enum].GetNames(clientFolderName) > MsgBox(x) > Next > > "Keith G Hicks" <k***@comcast.net> wrote in > messagenews:uFHfC4a$KHA.1***@TK2MSFTNGP02.phx.gbl... > > >I want to run through an enumeration in a loop for scanning client sub > >folders. > > > Base folder is D:\TestStuff\ > > > Subfolders in that are Jones, Smith, Ryan (there could be several more > > and > > will not be named this simple) > > > I want to run a loop that goes through those folders one at a time like > > this: > > > For x = Jones to Ryan > > .... check for files in each sub folder and do a bunch of processing > > Next x > > > I thought I could do soemthing with enumerations where the enum would be > > defined like this: > > > Private enum clientFolders > > Jones = 1 > > Smith = 2 > > Ryan = 3 > > End Enum > > > Then I could do something like this > > > For x = 1 to 3 > > msgbox(clientFolders.x) > > next x > > > But that doens't work. I'm not sure how to do this. > > > Thanks, > > > Keith > In addition to Patrice's comments, what will you do when you decide to > add another user in the future? Are you going to change your code > every time? for importing data from spreadsheets submitted by the clients and each client has a different layout so the code is entirely different in each case. Each time a new client is going to be added to this process, I will be writing a new hunk of code specifically for that client. So yes, it won't happen very often but I will have to rewrite the code each time. I know how to scan for folders. Just can't make use of that idea in this case at all.
display var value
Maximum index on a list is less than the list size Umm.... How to pass a sub into a class...... How do I get back deleted Tab Page DataTable - set a specific row. keep changes are made on datasource. an attempt was made to load a program with an incorrect format Crystal Reports in VB.NET Express Edition Re:Date Time Format Problem RE: Dockable windows |
|||||||||||||||||||||||