vb函数的返回值,该返回值作为余数 [英] vb function return value and this return value as arugment

查看:100
本文介绍了vb函数的返回值,该返回值作为余数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

function a(x As Integer,y As Integer ,output   z) As Integer
    z  =x+y;
    return  z;
end function



请给我发送代码.



please send me code.

推荐答案

您不需要第三个z参数.去掉它;它会起作用.
另外,将方法设为静态(在VB.NET中为"Shared"):

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

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



—SA


为什么要同时设置参数值然后从函数返回值.任何一个都足够
如下所述使用Sub
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
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



或使用解决方案1中给出的Function



or use the Function as given in Solution 1


认真地,在VB.NET上阅读一本初学者的书,并逐步进行学习.这是您要问的非常基本的概念.
Seriously, pickup a beginners book on VB.NET and work through it. This is very basic concept stuff your asking about.


这篇关于vb函数的返回值,该返回值作为余数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆