Legacy Timer Issue in VB.NET and VB6
Legacy Timer Issue in VB.NET and VB6
Legacy Timer Issue in VB.NET and VB6
Legacy Timer Issue in VB.NET and VB6
Legacy Timer Issue in VB.NET and VB6
Legacy Timer Issue in VB.NET and VB6 Legacy Timer Issue in VB.NET and VB6 Legacy Timer Issue in VB.NET and VB6 Legacy Timer Issue in VB.NET and VB6 Legacy Timer Issue in VB.NET and VB6 Legacy Timer Issue in VB.NET and VB6 Legacy Timer Issue in VB.NET and VB6 Legacy Timer Issue in VB.NET and VB6
Legacy Timer Issue in VB.NET and VB6 Legacy Timer Issue in VB.NET and VB6
Legacy Timer Issue in VB.NET and VB6
Go Back  Xtreme Visual Basic Talk > > > Legacy Timer Issue in VB.NET and VB6


Reply
 
Thread Tools Display Modes
  #1  
Old 11-25-2015, 02:04 PM
Cerian Knight's Avatar
Cerian KnightLegacy Timer Issue in VB.NET and VB6 Cerian Knight is offline
Polymath (in disciplina)

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 4,193
Default Legacy Timer Issue in VB.NET and VB6


I think this speaks for itself. I've posted on this issue before and finally got around to testing it in .NET. Non-legacy timers were not tested in VB.Net (for comparison).
Code:
'Demonstrate negative temporal displacement issue with Legacy Timer accumulated in 'I' (workarounds provided accumulated in 'J' and 'K')
'Bad in VB.NET 2013 and VB6(SP6)
'Good in VBA 2007 (not tested in previous versions of VBA)
'Sample output VB.NET: 400594  0	0
'Sample output VB6:  2113186  0  0 

Imports Microsoft.VisualBasic

Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim T0 As Single
        Dim T1 As Single
        Dim T2 As Single
        Dim I As Long, J As Long, K As Long
        T0 = Timer
        Do
            T1 = Timer
        Loop While T1 - T0 < 1 'Loop for one second
        T0 = Timer
        Do
            T1 = Timer : If Timer - T1 < 0 Then I = I + 1 'Bad
        Loop While T1 - T0 < 1 'Loop for one second
        T0 = Timer
        Do
            T1 = Timer : If CSng(Timer) - T1 < 0 Then J = J + 1 'Good
        Loop While T1 - T0 < 1 'Loop for one second
        T0 = Timer
        Do
            T1 = Timer : T2 = Timer : If T2 - T1 < 0 Then K = K + 1 'Good
        Loop While T1 - T0 < 1 'Loop for one second
        TextBox1.Text = CStr(I) & vbTab & CStr(J) & vbTab & CStr(K)
    End Sub
End Class
__________________
I got all the answers wrong on the GLAT, apparently even #9 (where I put a period in the middle of the box and labeled it 'singularity ripe for rapid inflation').
Reply With Quote
Reply

Tags
timer, loop, vb.net, dim, single, issue, output, vba, bad, legacy, sample, vb6, accumulated, vbtab, tested, class, form1_loadsender, mybase.load, form1, private, cstrk, cstrj, textbox1.text, eventargs, cstri


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Legacy Timer Issue in VB.NET and VB6
Legacy Timer Issue in VB.NET and VB6
Legacy Timer Issue in VB.NET and VB6 Legacy Timer Issue in VB.NET and VB6
Legacy Timer Issue in VB.NET and VB6
Legacy Timer Issue in VB.NET and VB6
Legacy Timer Issue in VB.NET and VB6 Legacy Timer Issue in VB.NET and VB6 Legacy Timer Issue in VB.NET and VB6 Legacy Timer Issue in VB.NET and VB6 Legacy Timer Issue in VB.NET and VB6 Legacy Timer Issue in VB.NET and VB6 Legacy Timer Issue in VB.NET and VB6
Legacy Timer Issue in VB.NET and VB6
Legacy Timer Issue in VB.NET and VB6
 
Legacy Timer Issue in VB.NET and VB6
Legacy Timer Issue in VB.NET and VB6
 
-->