Click here to Skip to main content
15,897,147 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
VB
function a(x As Integer,y As Integer ,output   z) As Integer
    z  =x+y;
    return  z;
end function


please send me code.
Posted
Updated 18-Mar-12 23:25pm
v2
Comments
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

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
 
Share this answer
 
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
 
Share this answer
 
Seriously, pickup a beginners book on VB.NET and work through it. This is very basic concept stuff your asking about.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900