This documentation is archived and is not being maintained.

DoEvents no longer returns a value

Visual Studio .NET 2003

In previous versions of Visual Basic, the DoEvents function returned an Integer value representing the number of open forms. In Visual Basic .NET, the DoEvents function is replaced by the DoEvents method; consequently, it has no return value. Attempting to call DoEvents as a function will cause the compiler error "No accessible overloaded method 'DoEvents' produces a value".

Note   The more common use of DoEvents was to yield execution to allow the system to process messages. In this case it was treated as a method with no return value. Code using DoEvents in this manner will migrate successfully to Visual Basic .NET.
' Visual Basic 6.0
Dim i As Integer
' Returns the number of open forms.
i = DoEvents
' Yields processing; no return value.

' After upgrade to Visual Basic .NET
Dim i as Short
' Causes a compiler error.
i = System.Windows.Forms.Application.DoEvents()
' Compiles successfully.

What to do next

  • Change the DoEvents function to a method as in the above example.
  • Review your code to determine how the return value of the DoEvents function was being used and modify your code as necessary.
    Note   There is no equivalent function in Visual Basic .NET that returns the number of open forms.

See Also

Programming Element Support Changes Summary