VB.Net Tutorial/Class Module/Function Parameters — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 15:55, 26 мая 2010
Argument Order
<source lang="vbnet">Imports System Public Module Test
Public Function Add(ByVal Num1 As Integer, ByVal Num2 As Double) As Double Return Num1 + Num2 End Function Public Function Add(ByVal Num2 As Double, ByVal Num1 As Integer) As Double Return Num1 - Num2 End Function Sub Main() Dim Num3 As Double = Add(2, 4.2) Dim Num4 As Double = Add(4.2 , 2) Console.WriteLine("The first Add Method " & Num3) Console.WriteLine("The Second Add Method " & Num4) End Sub
End Module</source>
The first Add Method 6.2 The Second Add Method -2.2
Optional parameters
<source lang="vbnet">Module Module1
Sub Main() ShowMessage() End Sub Sub ShowMessage(Optional ByVal strText As String = "Hello there!") System.Console.WriteLine(strText) End Sub
End Module</source>
Hello there!