hi.
i have a piece of code that i wanna know that in how many miliseconds it would be run.

 Public Sub TurnLeft(ByVal speed As Single)
        Dim timer As Single
        If Not IsNothing(Me._DriveActor) Then
            'command below
            Me._DriveActor.Turn(speed)
        End If
    End Sub

i know that we have timer class but you can not get the number of milisecond that it would take.
thanks in advance.

You can get the number of milliseconds code takes to run by using the Stopwatch class:

Dim s As New Stopwatch()
s.Start()
' Place code you need to get the time it takes to run in here
s.Stop()
Dim elapsedtime As Integer = s.ElapsedMilliseconds
' elapsedtime now has how long it took to run in milliseconds

the stopwatch does n't have start and stop module

Be a part of the DaniWeb community

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