Trying to refer to a tool

  • (2 Pages)
  • +
  • 1
  • 2

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

#16 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 - 09:03 PM

View Postmodi123_1, on 05 February 2019 - 05:35 AM, said:

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.


I will create a test project when I get home and try to work with the grids. This is probably my first project to be actually fully completed I hope and then published for others to use. All my programs before this one were only to help myself on my PC or just to feel like I did something great, so I am really hoping this program can impress my colleagues! Who knows? Maybe I find the rest of the college interested in this and find myself making many copies for hundreds of students instead of only 80! One can always hope :)
I literally test each step I make on my Laptop and 2 other PC (3 in total) to make sure it works as intended on different PCs. I even went out to an internet cafe and tested my program on a few PCs there just to be sure lol
Was This Post Helpful? 0
  • +
  • -

#17 Sheepings   User is offline

  • Senior Programmer
  • member icon

Reputation: 201
  • View blog
  • Posts: 1,126
  • Joined: 05-December 13

Re: Trying to refer to a tool

Posted 04 February 2019 - 09:35 PM

I don't often see many serious devs come through the VB.Net forums any more with a program on your scale, and I admire how committed you are to completing it and wanting to go about it properly. Kudos to you. Also, apologies for the misleading reply above, its extremely late in the morning here, and my brain cells are almost burned out completely from working long hours. But I wish you well with the project Omarado. :)
Was This Post Helpful? 0
  • +
  • -

#18 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 05 February 2019 - 02:26 PM

So guys , I just tried out the code I found and it actually works just as I watned!

Imports System.IO
Public Class Form1
    Dim CurDir As String = My.Application.Info.DirectoryPath
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim thelist As String
        Dim eachfile As String
        Dim lab As Label
        Dim di As DirectoryInfo = My.Computer.FileSystem.GetDirectoryInfo(CurDir)
        For Each fi As FileInfo In di.GetFiles()
            eachfile = (System.IO.Path.GetFileNameWithoutExtension(fi.FullName))
            thelist = thelist & (System.IO.Path.GetFileNameWithoutExtension(fi.FullName)) & vbCrLf
            lab = Me.Controls(eachfile)
            Try
                lab.ForeColor = Color.Green
            Catch ex As Exception
            End Try
        Next fi
        MsgBox(thelist)
    End Sub
End Class



I tried this on a test project where I had 3 labels. The code is simple: if a file is found with the same name as any of the labels. the corresponding label will turn green. I tried the code and the label with the same name as a file in the target directory actually turned green! and it also worked when all 3 labels had a matching file found! Only problem I encountered is if there is a file in the directory with a name but without a matching label. Like for example if a file named [Tester] was found but there was actually no control with the same name then an error of (Object reference is not set to an object) will pop up. I avoided this by adding a Try - Catch on the part where it assigns a color to the control without adding a code in the Catch block as you see in the code above. This suppresses the error and the program continues to work as intended without any other problems. What do you guys think of this?
Was This Post Helpful? 0
  • +
  • -

#19 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14854
  • View blog
  • Posts: 59,272
  • Joined: 12-June 08

Re: Trying to refer to a tool

Posted 05 February 2019 - 02:30 PM

It's painful on multiple levels, but hey - if it works for you now go nuts.

In general - you shouldn't be swallowing exceptions, but instead programming to prevent them.
Also you shouldn't be relying on your UI components for data and comparison. It should be in some collection or group of classes.. but hey.. for being a hobbyist go crazy.
Was This Post Helpful? 0
  • +
  • -

#20 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 05 February 2019 - 08:03 PM

View Postmodi123_1, on 05 February 2019 - 11:30 PM, said:

It's painful on multiple levels, but hey - if it works for you now go nuts.

In general - you shouldn't be swallowing exceptions, but instead programming to prevent them.
Also you shouldn't be relying on your UI components for data and comparison. It should be in some collection or group of classes.. but hey.. for being a hobbyist go crazy.


I am not a professional yet. I program as a hobby indeed not for a job or something. I try to improve myself as I go , could you tell me what do you exactly mean by comparing in classes?
Was This Post Helpful? 0
  • +
  • -

#21 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14854
  • View blog
  • Posts: 59,272
  • Joined: 12-June 08

Re: Trying to refer to a tool

Posted 05 February 2019 - 08:28 PM

So your UI is to display data, right? In theory you would have a data object, or collection of objects, that is the actual backing of what is being displayed. Be it a list of strings, a dictionary, etc. That is your 'model'. Your UI is your 'view'.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2