hey guys im fairly new to visual basic, but very eager to learn it. I am attempting to make an employee clock in.

I want to make a simple clock in that will ask the user to enter their name, and just click a button that will then post that time.

I would then like to get the time and name of the user and dump it into a .txt file

Is there anyway that when the user clicks a button i can grab the current system time and throw it into a label?

How can the program save the information. The user will be clicking on the .exe of the program. When they clock in and the time is visible on the form they will exit the program. Will the program automatically save the clock in time inside the label or when the program restarts it will need to read the time from the .txt file?

Recommended Answers

All 4 Replies

I think this addresses your needs:

Private Sub btnClockIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClockIn.Click
        Dim Time As String = Now()
        Dim Name As String = txtName.Text

        'writes time to label on form
        lblTime.Text = Time

        'write to file
        Dim oFile As System.IO.File
        Dim oWrite As System.IO.StreamWriter
        oWrite = oFile.CreateText("C:/test.txt")

        oWrite.WriteLine(Name & "," & Time)

        oWrite.Close()

End Sub
commented: Timely... And Well Written. +10

i made a simple one like this one:

Using outFile As StreamWriter = New StreamWriter("blahblah.txt")

   outFile.Write("Clock In: " + TimeOfDay)


End Using

I was wondering if it was possible to include the name of the current user logged into the computer to the text file. Could this be done?

i made a simple one like this one:

Using outFile As StreamWriter = New StreamWriter("blahblah.txt")

   outFile.Write("Clock In: " + TimeOfDay)


End Using

I was wondering if it was possible to include the name of the current user logged into the computer to the text file. Could this be done?

You might try this:

Dim UserName As String = Environ("USERNAME")

My.User.Name

Environment.UserName.ToString()

You can checkout the My or Environment objects to find more interesting things.

The My.Computer.Clock object provides properties to find the current local time for the computer and the UTC time. It also exposes the millisecond count from the computer's system timer.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.