DoEvents no longer returns a value

In previous versions of Visual Basic, the DoEvents function returned an Integer value representing the number of open forms. In Visual Basic 2008, the DoEvents function is replaced by the M:System.Windows.Forms.Application.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 2005.

' Visual Basic 6.0
Dim i As Integer
' Returns the number of open forms.
i = DoEvents
' Yields processing; no return value.
DoEvents

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

What to do next

  1. Change the DoEvents function to a method as in the above example.

  2. 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 2008 that returns the number of open forms.

See Also

Concepts

Programming Element Support Changes Summary