[mono-vb] functions parameter order example

Jude DaShiell jdashiel at shellworld.net
Mon Apr 13 04:27:23 EDT 2009


cut here.
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

I used a cut and paste facility in speakup-linux to copy this example into 
this message.  When I try to compile it using vbnc, I get a less generic 
error and not 6.2 and 2.2 as the results for the first add method and 
second add method respectively.  The error gets generated on the second 
add method output line strangely enough.  I would have thought the error 
would have happened further up in the program where the calculation 
happened but that wasn't the case over here.  This came from 
http://www.java2s.com in the vb.net tutorial -> class modules -> argument 
order link.




More information about the Mono-vb mailing list