My.Forms 和 My.WebServices 物件可讓您存取應用程式所使用的表單、數據源和 XML Web 服務。 它們透過每個這些物件的預設的實例集合來提供存取權。
預設例項
默認實例是運行時間所提供的 類別實例,不需要使用 Dim 和 New 語句來宣告和具現化。 下列範例示範如何宣告和具現化名為Form的Form1類別實例,以及如何透過 取得此Form類別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()
物件 My.Forms 會傳回專案中每個 Form 類別的預設實例集合。 同樣地, My.WebServices 針對您已在應用程式中建立參考的每個 Web 服務,提供 Proxy 類別的預設實例。