本文介绍了重载功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个函数Sum作为....
函数和(ByVal ParamArray值()As Double)As Double
Dim rSum,itm As Double
每个价值每个价值
rSum + = itm
下一个
返回rSum
结束功能
我认为这个功能很通用,但是当我尝试
计算总和时出现问题一系列单打。我真的必须为单个,长整数,短整数,字节等做一个
重载函数吗?
还是有更好的方法吗?
TIA
/ Kejpa
Hi,
I have a function Sum as....
Function Sum(ByVal ParamArray Values() As Double) As Double
Dim rSum, itm As Double
For Each itm In Values
rSum += itm
Next
Return rSum
End Function
This function is general enough I think, but troubles arise when I try to
calculate the sum of an array of singles. Do I really have to make an
overloaded function for single, long, integer, short, byte and whatnot?
Or is there a better approach?
TIA
/Kejpa
推荐答案
这篇关于重载功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!