15,918,624 members
See more:
VB
```function a(x As Integer,y As Integer ,output   z) As Integer
z  =x+y;
return  z;
end function```

Posted
Updated 18-Mar-12 23:25pm
v2
Sergey Alexandrovich Kryukov 19-Mar-12 4:01am
Not a question. A code for what?!
--SA
OriginalGriff 19-Mar-12 4:04am
Sorry, but that doesn't make any sense.
You are asking for code, but all you have done is show us code which fits the description of your problem.
What do you want us to do?
Use the "Improve question" widget to edit your question and provide better information.
ProEnggSoft 19-Mar-12 5:26am
Edit: pre tag for VB code added - PES

## Solution 1

You don't need the third `z` parameter. Remove it; and it will work.
Also, make the method static ("Shared" in VB.NET):

VB
```Private Shared Function A(x As Integer, y As Integer) As Integer
Return x + y
End Function

'usage:
Dim x As Integer = '...
Dim y As Integer = '...
Dim z As Integer = A(x, y)```

—SA

## Solution 2

Why do you want to both set the value of argument and then return the value from the function. Any one is sufficient
Either use `Sub `as below
VB
```Sub Main
Dim x as Integer, y as Integer, z as Integer
x=5
y=10
A(x,y,z)
Console.WriteLine(z)
End Sub

Public Sub A(ByVal x as Integer, ByVal y as Integer, ByRef z as Integer)
'Set the value in the ByRef parameter
z = x + y
End Sub```

or use the `Function `as given in Solution 1

## Solution 3

Seriously, pickup a beginners book on VB.NET and work through it. This is very basic concept stuff your asking about.