Vb.net-with-statement

提供:Dev Guides
移動先:案内検索

VB.Net-と…​ ステートメントで終了

正確にループ構造ではありません。 単一のオブジェクトまたは構造を繰り返し参照する一連のステートメントを実行します。

このループ構造の構文は次のとおりです-

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