Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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! :(

  • Administrators
Posted
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)

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...