andru Posted November 1, 2003 Posted November 1, 2003 Hey guys, I'm new to VB.NET and really unfamiliar with the syntax. I made one button, so when it's clicked, variable: StartTime = Now Similarly, another button when clicked is: EndTime = Now How do I find the elapsed time? i.e. ElapsedTime = EndTime - StartTime? I get the msg "Operator is not valid for type 'Date' and 'Date'." Help this newbie with such a simple question please! :( Quote
Administrators PlausiblyDamp Posted November 1, 2003 Administrators Posted November 1, 2003 Dim startTime As Date = Date.Now Dim endTime As Date do something here Dim i As Integer For i = 1 To 10000 Application.DoEvents() Next endTime = Date.Now Dim diff As TimeSpan = endTime.Subtract(startTime) MessageBox.Show(diff.TotalSeconds.ToString) Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
andru Posted November 1, 2003 Author Posted November 1, 2003 Thanks, but how I get it into hh:mm:ss format? Quote
Administrators PlausiblyDamp Posted November 3, 2003 Administrators Posted November 3, 2003 Not near VS.Net at the moment so I may be wrong but I thing the DateTime class can be created from a TimeSpan (I think it is one of the overload new methods). Doing that will allow you to then use the dates .ToLongTime method. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.