arrays - vb.net for each loop counter -


i trying make program organize folders full of random stuff. want put each file type folder describes in it. have arrays of file types inside array can loop through.

it can move file types specified in array fine, when tried make put each type seperate folder, says array index out of bounds.

it works fine if replace index of names number, can't change automatically.

here code using:

dim extensions array = {audio, video, image, document, plaintext, batch, powershell, vb, diskimage, compressed, excutable, model, code, web, registry} dim names string() = {"audio", "videos", "pictures", "documents", "text documents", "batch", "powershell", "visual basic", "diskimages", "compressed files", "excutables", "3d models", "code", "web", "registry"}      dim number integer = 0     each type string() in extensions         number += 1         path = path + names(number)          each extension string in type             label2.text = extension             copymove(folderbrowserdialog2.selectedpath, path, extension, s)         next      next 

paired arrays such poor practice. better create class , use single array or list of class:

public class filetype     public property category string        public property extensions list(of string) end class  dim filetypes new list(of filetype) {     new filetype() {category = "audio", extensions = audio },     new filetype() {cateogry = "video", extensions = video }     '... }    each type filetype in filetypes     dim thispath string = path.combine(path, type.category)      each extension string in type.extensions         label2.text = extension ' label won't update inside method, that's question         copymove(folderbrowserdialog2.selectedpath, thispath, extension, s)     next next 

Comments

Popular posts from this blog

php - Admin SDK -- get information about the group -

dns - How To Use Custom Nameserver On Free Cloudflare? -

Python Error - TypeError: input expected at most 1 arguments, got 3 -