Wednesday, August 10, 2011

nandini-return type in VB


Here's the formal syntax for functions you use the Function statement:

[ <attrlist> ] [{ Overloads | Overrides | Overridable | 
NotOverridable | MustOverride | Shadows | Shared }]
[{ Public | Protected | Friend | Protected Friend | 
Private }] Function name[(arglist)] [ As type ]
[ Implements interface.definedname ]
  [ statements ]
  [ Exit Function ]
  [ statements ]
End Function
Example:
 Sub Main()
    Dim intX As Integer = 2
    Dim intY As Integer = 3
    Console.WriteLine(intX & " + " & _
      intY & " = " & Sum(intX, intY))
    Console.WriteLine("Press Enter to continue...")
    Console.ReadLine()
  End Sub

  Function Sum(ByVal a As Integer, ByVal b As Integer) As Long
    Return a + b
  End Function
  For more information visit: www.gurukpo.com 

No comments:

Post a Comment