**** Merged from MCS ****
[mono-project.git] / mcs / mbas / Test / errors / OptionalArgu_ByFunctionA2.vb
blobe62fee54d932a69e0bc2ea1d6f4e95ec7783c8c9
1 REM LineNo: 24
2 REM ExpectedError: BC30202
3 REM ErrorMessage: 'Optional' expected.
5 REM LineNo: 25
6 REM ExpectedError: BC30815
7 REM ErrorMessage: 'name' is not declared. File I/O functionality is available in the 'Microsoft.VisualBasic' namespace.
9 REM LineNo: 36
10 REM ExpectedError: BC30057
11 REM ErrorMessage: Too many arguments to 'Public Function F(telephoneNo As Long, [code As Integer = 80], [code1 As Integer = 91]) As Boolean'.
13 '=============================================================================================
14 'Name:Manish Kumar Sinha
15 'Email Address: manishkumarsinha@sify.com
16 'Test Case Name: Argument passing by Optional Keyword:
17 'O.P-1.0.2: An Optional parameter must specify a constant expression to be used a replacement
18 ' value if no argument is specified. After Optional parameter we can't use general
19 ' parameter as ByVal or ByRef
20 '=============================================================================================
22 Imports System
23 Module OP1_0_2
24 Function F(ByVal telephoneNo as Long, Optional ByVal code as Integer = 080,Optional ByVal code1 As Integer = 091, ByRef name As String) As Boolean
25 if (code <> 080 and code1 <> 091 and name="")
26 return false
27 else
28 return true
29 end if
30 End Function
32 Sub Main()
33 Dim telephoneNo As Long = 9886066432
34 Dim name As String ="Manish"
35 Dim status as Boolean
36 status =F(telephoneNo,,,name)
37 if(status = false)
38 Throw New System.Exception("#A1, Unexcepted behaviour in string of OP1_0_2")
39 end if
40 End Sub
42 End Module