Compartir a través de


Default Object Instances Provided by My.Forms and My.WebServices (Visual Basic)

The My.Forms and My.WebServices objects provide access to forms, data sources, and XML Web services used by your application. They do this by providing collections of default instances of each of these objects.

Default Instances

A default instance is an instance of the class that is provided by the runtime and does not need to be declared and instantiated using the Dim and New statements. The following example demonstrates how you might have declared and instantiated an instance of a Form class called Form1, and how you are now able to get a default instance of this Form class through My.Forms.

' The old method of declaration and instantiation 
Dim myForm As New Form1
myForm.show()
' With My.Forms, you can directly call methods on the default  
' instance()
My.Forms.Form1.Show()

The My.Forms object returns a collection of default instances for every Form class that exists in your project. Similarly, My.WebServices provides a default instance of the proxy class for every Web service that you have created a reference to in your application.

See Also

Reference

My.Forms Object

My.WebServices Object

Concepts

How My Depends on Project Type (Visual Basic)