VB.Net - With... End With 語句



它不是一個迴圈結構。它執行一系列重複引用單個物件或結構的語句。

此迴圈結構的語法為 -

With object
   [ statements ]
End With

示例

Module loops
   Public Class Book
      Public Property Name As String
      Public Property Author As String
      Public Property Subject As String
   End Class
   Sub Main()
      Dim aBook As New Book
      With aBook
         .Name = "VB.Net Programming"
         .Author = "Zara Ali"
         .Subject = "Information Technology"
      End With
      With aBook
         Console.WriteLine(.Name)
         Console.WriteLine(.Author)
         Console.WriteLine(.Subject)
      End With
      Console.ReadLine()
   End Sub
End Module

編譯並執行以上程式碼後,它會生成如下結果 -

VB.Net Programming
Zara Ali
Information Technology
vb.net_loops.htm
廣告
© . All rights reserved.