Trying to refer to a tool

  • (2 Pages)
  • +
  • 1
  • 2

20 Replies - 424 Views - Last Post: 05 February 2019 - 08:28 PM Rate Topic: -----

#1 Omarado   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 91
  • Joined: 22-September 15

Trying to refer to a tool

Posted 04 February 2019 - 10:43 AM

This may sound complicated but I can't figure out what to do now ...
I have a folder with a list of files, those files names match the Names of some tools I have in my application.
I have managed to create a code that gets the list of files in a specific folder/directory.
What I want to do is using a (For ... Next) method. I would apply a code to the tool carrying the same name as the file one by one...

Here's the code I have:

Public Sub FileScanPPlec()
        Dim thefiles As String
        Dim TheTool As Object
        Dim di As DirectoryInfo = My.Computer.FileSystem.GetDirectoryInfo(CurDir)
        For Each fi As FileInfo In di.GetFiles()
            thefiles = thefiles & (System.IO.Path.GetFileNameWithoutExtension(fi.FullName)) & vbCrLf

        Next fi
        MsgBox(thefiles)
    End Sub



for example , if the program finds a file named "HeyBuddy" then the tool named "HeyBuddy" will have something applied to it. The tool will most likely be a LinkLabel. I can't get past getting the list of file names, Any help would be appreciated.

Is This A Good Question/Topic? 0
  • +

Replies To: Trying to refer to a tool

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14761
  • View blog
  • Posts: 59,010
  • Joined: 12-June 08

Re: Trying to refer to a tool

Posted 04 February 2019 - 10:52 AM

I am a curious cat - so.. ah.. why? Why all this crazy indirection, files of names of tools in places that then have magical things applied to them if there? This seems so far around the bush it ended up in Tasmania.
Was This Post Helpful? 0
  • +
  • -

#3 Omarado   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 91
  • Joined: 22-September 15

Re: Trying to refer to a tool

Posted 04 February 2019 - 11:18 AM

View Postmodi123_1, on 04 February 2019 - 07:52 PM, said:

I am a curious cat - so.. ah.. why? Why all this crazy indirection, files of names of tools in places that then have magical things applied to them if there? This seems so far around the bush it ended up in Tasmania.


The point is I need to scan for files present in a specific directory and then if the files don't exist there then the buttons for the missing files are disabled and if they exist there then the buttons for the present files are enabled and clicking those buttons will open the files. I could go the long way and make the code for each individual button but that will take so long since I have around 620 buttons which will use the same method so I am trying to find a way around writing 620 lines of code which possibly could be shortened to a few lines which will also save me time so I can finish the rest of the project.

This post has been edited by Omarado: 04 February 2019 - 11:20 AM

Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14761
  • View blog
  • Posts: 59,010
  • Joined: 12-June 08

Re: Trying to refer to a tool

Posted 04 February 2019 - 11:56 AM

620 buttons? Like, for real?

I am just super curious on the 'why' and can't seem to wrap my head around the business case this solves. Help a brother out?

Just a curious cat on the larger hows and whys. :^:
Was This Post Helpful? 0
  • +
  • -

#5 Sheepings   User is offline

  • Senior Programmer
  • member icon

Reputation: 195
  • View blog
  • Posts: 1,089
  • Joined: 05-December 13

Re: Trying to refer to a tool

Posted 04 February 2019 - 12:13 PM

Why on earth would you possibly need 640 buttons? :lol: What :eek:
Was This Post Helpful? 0
  • +
  • -

#6 Omarado   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 91
  • Joined: 22-September 15

Re: Trying to refer to a tool

Posted 04 February 2019 - 01:50 PM

View Postmodi123_1, on 04 February 2019 - 08:56 PM, said:

620 buttons? Like, for real? I am just super curious on the 'why' and can't seem to wrap my head around the business case this solves. Help a brother out?Just a curious cat on the larger hows and whys. :^:/>/>



View PostSheepings, on 04 February 2019 - 09:13 PM, said:

Why on earth would you possibly need 640 buttons? :lol:/>/> What :eek:/>/>


Well ... I am in the faculty of pharmacy and since I know basic programming , my friends suggested that I make a program to help out with managing all the files we have and for easier communication between us. Our number is 80 students. I use Google Drive to store all the data and I am able to download them through the program without problems with a secure sign in. The part which is being a problem to me is those 620 buttons or to be exact linklabels. We have 7 subjects and each subject is divided onto 14 lectures and 2 revisions. Each lecture has 6 different files. so by doing Math:
16 X 6 = 96 and since we have 7 subjects then , 96 X 7 = 672 but since each revision only has 2 files instead of 6 so the number is exactly 616 linklabels/buttons.

The program on startup should scan for files on the PC. found files will have their linklabel in Green meaning that are available on the PC and can be opened on click. if the file isn't present then another task is done to check if it is available online , If it is the linklabel is turned Red which means the file is available online and clicking the linklabel will download the file then open it. If the file isn't on the PC nor online then the linklabel is disabled completely.

All of this is the story behind the program. It isn't required for a homework/project.It is just something done for me and my colleagues to help us with our study. I know how to do all the stuff the program needs to do. I just need a shorter way and more efficient way to do this quicker. I want to write the code 1 time instead of writing 616 times because this takes way too long to do.

I just need a way so that when [Example] file is found then the linklabel named [Example] has its linkcolor turned to Green and so on. I need to know how to do this so I can just make a [For ... Next] Loop all the files. I can't figure out how to do that.

Here's an image to understand why the program has 616 Buttons/LinkLabels:
Attached Image

This isn't the final design but is a start, The LinkLabels in this images are disabled by default
Copy that screen to 6 other Tabs for a total of 7 tabs of 7 subjects.

This post has been edited by Omarado: 04 February 2019 - 01:52 PM

Was This Post Helpful? 1
  • +
  • -

#7 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14761
  • View blog
  • Posts: 59,010
  • Joined: 12-June 08

Re: Trying to refer to a tool

Posted 04 February 2019 - 02:18 PM

Oh wow... Ooooooooookay. So this is just something to manage homework turned in by students?

Giving me a few minutes to digest this there are probably better tools to use. DataGrids, treeview controls, etc all come to mind as concise things to handle displaying large volumes of information that have a consistent format.
Was This Post Helpful? 0
  • +
  • -

#8 Omarado   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 91
  • Joined: 22-September 15

Re: Trying to refer to a tool

Posted 04 February 2019 - 02:24 PM

View Postmodi123_1, on 04 February 2019 - 11:18 PM, said:

Oh wow... Ooooooooookay. So this is just something to manage homework turned in by students?


Our Doctors give lectures and those are rewritten in a more simple way and one of us records it. We have them all uploaded but not organized. The program's job is to organize them and make it easier to navigate through them. Our lecturers and doctors have nothing to do with this program at all.
Was This Post Helpful? 0
  • +
  • -

#9 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14761
  • View blog
  • Posts: 59,010
  • Joined: 12-June 08

Re: Trying to refer to a tool

Posted 04 February 2019 - 02:27 PM

Hmmmm... Give me a few to think on this. The idea of having to generate 620 link label objects on the fly, with appropriate events, doesn't sit well.

I am thinking a grid or a tree would be best.. but thinking cap is on.
Was This Post Helpful? 0
  • +
  • -

#10 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14761
  • View blog
  • Posts: 59,010
  • Joined: 12-June 08

Re: Trying to refer to a tool

Posted 04 February 2019 - 02:40 PM

Ultimately yeah.. I would think going a different route with the UI would be better, but that's up to you.

In theory you would need to create an instance of the link label control, give it a name, give it text, color it, location, etc and then add it to your immediate container.

Example - here is create a click button, providing some information, and adding it to the main form's control group. That could easily be a panel or some other container.

        Dim foo As New Button
        foo.Name = "foo"
        foo.Text = "bar"
        foo.Dock = DockStyle.Top
        Me.Controls.Add(foo)

Was This Post Helpful? 0
  • +
  • -

#11 Omarado   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 91
  • Joined: 22-September 15

Re: Trying to refer to a tool

Posted 04 February 2019 - 07:38 PM

View Postmodi123_1, on 04 February 2019 - 11:40 PM, said:

Ultimately yeah.. I would think going a different route with the UI would be better, but that's up to you.

In theory you would need to create an instance of the link label control, give it a name, give it text, color it, location, etc and then add it to your immediate container.

Example - here is create a click button, providing some information, and adding it to the main form's control group. That could easily be a panel or some other container.

        Dim foo As New Button
        foo.Name = "foo"
        foo.Text = "bar"
        foo.Dock = DockStyle.Top
        Me.Controls.Add(foo)


I see but that would require me to delete all the current link labels which are already named. Also won't that take even more time and put more load on the program? Having to programatically create all the buttons and place them. I have found something on the internet that could be what I am looking for but I am not home at the moment. Once I am home , I will test it and see if it works. If it goes well I will post the code here.

For now , what do you suggest regarding the UI? would it have to involve deleting all linklabels and recreating them again or just sort and move them around?
Was This Post Helpful? 0
  • +
  • -

#12 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14761
  • View blog
  • Posts: 59,010
  • Joined: 12-June 08

Re: Trying to refer to a tool

Posted 04 February 2019 - 07:40 PM

Like I said - I would think using a Grid or a Tree would be best. So far it looks to be similar styled information and those two are probably the best shot.
Was This Post Helpful? 0
  • +
  • -

#13 Omarado   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 91
  • Joined: 22-September 15

Re: Trying to refer to a tool

Posted 04 February 2019 - 07:43 PM

View Postmodi123_1, on 05 February 2019 - 04:40 AM, said:

Like I said - I would think using a Grid or a Tree would be best. So far it looks to be similar styled information and those two are probably the best shot.


I never used them before... Would they require deleting any of the already created link labels?
Was This Post Helpful? 0
  • +
  • -

#14 Sheepings   User is offline

  • Senior Programmer
  • member icon

Reputation: 195
  • View blog
  • Posts: 1,089
  • Joined: 05-December 13

Re: Trying to refer to a tool

Posted 04 February 2019 - 08:06 PM

I really can't see how, but it all depends on how you implement your changes and what you change. I think I'd also recommend the same suggestion above. Look at a treeview first. DataGrids and ListViews are a bit more advanced.

Apologies miss understood the question. Nothing to see here :)

This post has been edited by Sheepings: 04 February 2019 - 09:23 PM

Was This Post Helpful? 0
  • +
  • -

#15 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14761
  • View blog
  • Posts: 59,010
  • Joined: 12-June 08

Re: Trying to refer to a tool

Posted 04 February 2019 - 08:35 PM

Yes.. grids would remove the need for any of the link labels.

I appreciate the amount of work you have dumped into this, but honestly - this rabbit hole is the wrong one. Back up, back out, and regroup.
Was This Post Helpful? 1
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2