VB.Net Tutorial/Class Module/Sub — различия между версиями

Материал из VB Эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Текущая версия на 15:55, 26 мая 2010

Define a sub routine and call it

<source lang="vbnet">Option Strict On

Imports System

Module Module1
   Sub Main( )
      Console.WriteLine("In Main! ")
      SomeMethod( )
      Console.WriteLine("Back in Main( ).")
   End Sub "Main
   Sub SomeMethod( )
      Console.WriteLine("Greetings from SomeMethod!")
   End Sub 
End Module</source>
In Main!
Greetings from SomeMethod!
Back in Main( ).

Sub procedure that prints payment information.

<source lang="vbnet">Module Tester

  Sub Main()
     PrintSub(40, 10.5)
     PrintSub(38, 21.75)
     PrintSub(20, 13)
     PrintSub(50, 14)
  End Sub
  Sub PrintSub(ByVal hours As Double, ByVal wage As Decimal)
     Console.WriteLine("The payment is {0:C}", hours * wage)
  End Sub

End Module</source>

The payment is $420.00
The payment is $826.50
The payment is $260.00
The payment is $700.00