Skip to main content

Progress on the Pet Project

So, I don't have much, but I do have some. Behold my genius code for my hours calculation:

    Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
        Dim s1 As Integer
        Dim s2 As Integer
        Dim s3 As Integer
        Dim s4 As Integer
        s1 = Val(txtTimeInSunday.Text)
        s2 = Val(txtTimeOutLunchSunday.Text)
        s3 = Val(txtTimeInLunchSunday.Text)
        s4 = Val(txtTimeOutSunday.Text)
        lblSundayHoursTotal.Text = s4 - s1 - (s3 - s2)

        Dim m1 As Integer
        Dim m2 As Integer
        Dim m3 As Integer
        Dim m4 As Integer
        s1 = Val(txtTimeInMonday.Text)
        s2 = Val(txtTimeOutLunchMonday.Text)
        s3 = Val(txtTimeInLunchMonday.Text)
        s4 = Val(txtTimeOutMonday.Text)
        lblMondayHoursTotal.Text = m4 - m1 - (m3 - m2)

        Dim t1 As Integer
        Dim t2 As Integer
        Dim t3 As Integer
        Dim t4 As Integer
        s1 = Val(txtTimeInTuesday.Text)
        s2 = Val(txtTimeOutLunchTuesday.Text)
        s3 = Val(txtTimeInLunchTuesday.Text)
        s4 = Val(txtTimeOutTuesday.Text)
        lblTuesdayHoursTotal.Text = t4 - t1 - (t3 - t2)

        Dim w1 As Integer
        Dim w2 As Integer
        Dim w3 As Integer
        Dim w4 As Integer
        s1 = Val(txtTimeInWednesday.Text)
        s2 = Val(txtTimeOutLunchWednesday.Text)
        s3 = Val(txtTimeInLunchWednesday.Text)
        s4 = Val(txtTimeOutWednesday.Text)
        lblWednesdayHoursTotal.Text = w4 - w1 - (w3 - w2)

        Dim th1 As Integer
        Dim th2 As Integer
        Dim th3 As Integer
        Dim th4 As Integer
        s1 = Val(txtTimeInThursday.Text)
        s2 = Val(txtTimeOutLunchThursday.Text)
        s3 = Val(txtTimeInLunchThursday.Text)
        s4 = Val(txtTimeOutThursday.Text)
        lblThursdayHoursTotal.Text = th4 - th1 - (th3 - th2)

        Dim f1 As Integer
        Dim f2 As Integer
        Dim f3 As Integer
        Dim f4 As Integer
        s1 = Val(txtTimeInFriday.Text)
        s2 = Val(txtTimeOutLunchFriday.Text)
        s3 = Val(txtTimeInLunchFriday.Text)
        s4 = Val(txtTimeOutFriday.Text)
        lblFridayHoursTotal.Text = f4 - f1 - (f3 - f2)

        Dim sa1 As Integer
        Dim sa2 As Integer
        Dim sa3 As Integer
        Dim sa4 As Integer
        s1 = Val(txtTimeInSaturday.Text)
        s2 = Val(txtTimeOutLunchSaturday.Text)
        s3 = Val(txtTimeInLunchSaturday.Text)
        s4 = Val(txtTimeOutSaturday.Text)
        lblSaturdayHoursTotal.Text = sa4 - sa1 - (sa3 - sa2)


    End Sub

It's very crude, probably, but it's somewhat working. It's not giving me any more data than Sunday's total hours. Not sure why. Going to ask or research some on that part.

But, check it out! Actual living, breathing program!


When you click the Calculate button, it's supposed to calculate the Daily Total and Actual Hours. Then, it compares those to the Scheduled Hours, and if you meet or exceed those hours, you'll get a big grinning happy picture or something like that on the right. If not, some sad face. It's progress! And it's exciting! :D

Now, I'm aware that there is very likely an infinitely much easier method of calculating the hours. For a first attempt, and to see the math and everything involved, though, I am very proud.

Comments

Popular posts from this blog

Detailer Calculator GUI

I'm probably not done. I'm going to sit on this design for a day or two to see how it feels. I had a suggestion about adding a right triangle showing people base, slope, rise, angle, etc. I'm kind of torn on that part. In essence, this is probably about 90% done as far as the User Interface goes. I like it, I think. I'm hoping to be able to pass the keyboard strokes directly into the program, rather than have someone point and click. If I can get that done, the flow will be ten times better. I'm excited about the math involved and the fact that this will actually be functional. There are two things I'm struggling with right now. The first is the programming language. I've mentioned this before, I believe, but the programs my group works with are all programmed in VB.net. So, that's the language I'm learning right now. The problem, however, is that the system architect here at work is telling everyone that any new programs should be written in...

Big Scare

I learned an important lesson. Actually, I learned a few lessons. The first lesson - always back up. Have copies of files if backing up isn't easy. Next, it's a good idea to not proceed too far without checking to make sure everything still work, while you can still undo something. Third, and more specifically, apparently, renaming certain items in Visual Studio can completely erase a design. Let me explain... To recap, Visual Studio is the IDE I use to write my programs. I'm learning the VB.Net programming language because that's the language the software my company maintains was written in. It makes sense to get more familiar with that. I'm still extremely  new to Visual Studio, and I'm very new to coding and general coding principles. I'm reading tons of books (often at the same time) to get general coding practices, as well as very specific programming details for VB.Net. All this combined to say, I'm still learning, and I'm really new. No...