Sunday, January 27, 2008 10:30 PM
This is the first time i am using a forum
I need some help on making a timer in VB.Net but cant get my head around it i have done the rest of the programme but need to know how can i find out how long a person has been on the programme it has to include a start and end time and show the total time they have been on
Sunday, January 27, 2008 10:57 PMThere is a property Now that you can use in your VB.NET programs that returns the current date and time. Just save the value of this in a Date variable when the person starts using the program and then later you can compare this value with the current value of Now to see how long the person has been using the program.
Sunday, January 27, 2008 11:15 PM
i need to know how to rite the code i have two buttons and a tewxt box a start and stop button and a text box showing the total time
Monday, January 28, 2008 12:35 AMDo you need a realtime timer being shown, or just login time, log off. If you just need login/logoff time, you can just store the result of: "DateTime.Now" which will get the current time when you call it. Store the that when the user logs in, then call it again and store it in another variable when you log off, then you can take the difference of the two (which will return a timespan) to get a total time the user was logged in.
Monday, January 28, 2008 6:30 AMFor the guys who know their way around the Forums better or have a link saved, isnt there already some Code for folks who run an Internet Cafe to show how long someone has been on line with out using a third party piece of software. Do a search for Internet Cafe Time VB Code.
Wednesday, January 30, 2008 9:57 AM
You can do something like thisCode Snippet
Dim startTime As DateTime
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) _
startTime = DateTime.Now
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Dim t As TimeSpan = (DateTime.Now - startTime)
Me.TextBox1.Text = t.ToString