Re: start time/ stop time
I'm not sure I know exactly what you're asking for. Are you wanting to figure out how long the individual spent selecting items, or are you asking how to display the time when they began and then display it again when the end?
Also, please use the Code or Highlight tags when posting code.
Re: start time/ stop time
This part is certainly wrong:
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnstart.Click
Timer2.Enabled = True
rtxtbox.Text = rtxtbox.Text
End Sub
You are setting the text to the text, which does nothing. I would assume that you wanted to show the current time there, so perhaps this is just a simple typo.
Re: start time/ stop time
yes that shows how new to it i am normally if i spend enough time playing around i can figure it out but not this time.
what i am trying to do is i pick a computer from the drop down box and it goes into the text box.
2. i press start to record the start time and that goes into the box
3. i press end and that time goes into the box after that i will figure out how to calculate the time used :) hopefully.
Re: start time/ stop time
So don't you want something like this:
rtxtbox.Text = Date.now.Tostring
That would show the current date and time. It's not ideal, as you would also want to store the start time as a variable when the first button is pressed so that you can compare it to the time at the end. Since you would be putting the time into the textbox, you technically have it stored, but that would mean converting the date into a string to put it in the box, then converting the string back to a date. Not actually an issue, but not particularly efficient (though you would never notice the cost in speed).
Re: start time/ stop time
that worked i was trying the system date time now, when i try to put them into the text box in order each one just over rides the other meaning i press the computer from my drop down box that goes in then i add my start time that goes in the computer goes out and so on, i added chr (13) after them as i use this for my combo box to add a line break or is that also wrong.
well thxs shaggy your way gave me what i needed i added the code that i had in already and now i can get the computer in the box and the start and stop time the code i used is
rtxtbox.Text = rtxtbox.Text & Date.Now.ToString & Chr(13)
how hard would it be to work out the diff in time if it is really complicated ill leave it :) ill prob beback soon with another prob.
Re: start time/ stop time
rtxtbox.appendtext
Also look at environment.newline and stopwatch and timespan.
Re: start time/ stop time
where would i put the rtxtbox.appendtext at the moment i have a start time and end time in the text box s othe start time would say 10pm and the end time 11:20pm how would i work that out would i need a seperate code adding.
Re: start time/ stop time
Code:
'an example
rtxtbox.Clear()
rtxtbox.AppendText(DateTime.Now.ToString)
rtxtbox.AppendText(Environment.NewLine)
rtxtbox.AppendText(DateTime.Now.AddMinutes(60).ToString)
rtxtbox.AppendText(Environment.NewLine)
Re: start time/ stop time
would i add that into the form or the txtbox also how would i go about actually calculating the time diff i need to find the diff say it is 3 hours then i need to calculate a price.
if you know any good tutorial sites that would be helpful :) ( thats to everybody )
Re: start time/ stop time
Date math isn't difficult, but I deal with it so infrequently that I never remember it (I don't think I have even looked at it for about two years). I seem to remember questions about Date Add, DateAdd, or something like that, popping up every other month or so, so you might just search for one of those.
Re: start time/ stop time
Quote:
Originally Posted by
dbasnett
Code:
'an example
rtxtbox.Clear()
rtxtbox.AppendText(DateTime.Now.ToString)
rtxtbox.AppendText(Environment.NewLine)
rtxtbox.AppendText(DateTime.Now.AddMinutes(60).ToString)
rtxtbox.AppendText(Environment.NewLine)
You were doing this
rtxtbox.Text = rtxtbox.Text & Date.Now.ToString & Chr(13)
which replaces the contents. I thought you were trying to add text.
Code:
'SAMPLES
'
Dim Future As DateTime = #7/29/2010 9:12:34 AM#
Dim Present As DateTime = DateTime.Now
Dim theDiff As TimeSpan = Future - Present
'timespans do not have years
'theDiff.Days 'the days
'theDiff.Hours 'the hours
'theDiff.Minutes 'the minutes
'theDiff.Seconds 'the seconds