找回密码
 加入我们

QQ登录

只需一步,快速开始

搜索
查看: 6628|回复: 2

【原创】无限参数函数的编写方法

[复制链接]

1214

主题

352

回帖

11

精华

管理员

菜鸟

积分
93755

贡献奖关注奖人气王精英奖乐于助人勋章

发表于 2009-8-22 21:27:29 | 显示全部楼层 |阅读模式
<font face="Verdana">
<p><font face="Verdana">'阿杰编写于:2009年8月22日21:26:26<br/>Private Sub Form_Load()<br/>&nbsp;&nbsp;&nbsp; abc 1, 2, 3, 4, 5, 6, 7, 8, 9, 10<br/>End Sub</font></p>
<p><font face="Verdana">Sub abc(ParamArray 参数())<br/>Debug.Print "参数个数:", UBound(参数)<br/>s = 0<br/>&nbsp;&nbsp; For i = 0 To UBound(参数)<br/>&nbsp;&nbsp;&nbsp; s = s + 参数(i)<br/>&nbsp;&nbsp; Debug.Print 参数(i)<br/>&nbsp;&nbsp; Next<br/>&nbsp;&nbsp; Debug.Print "结果", s<br/>End Sub<br/></font></p>'结果:55</font>
[此贴子已经被作者于2009-8-22 21:30:58编辑过]
【VB】QQ群:1422505加的请打上VB好友
【易语言】QQ群:9531809  或 177048
【FOXPRO】QQ群:6580324  或 33659603
【C/C++/VC】QQ群:3777552
【NiceBasic】QQ群:3703755

1214

主题

352

回帖

11

精华

管理员

菜鸟

积分
93755

贡献奖关注奖人气王精英奖乐于助人勋章

 楼主| 发表于 2009-8-22 21:39:48 | 显示全部楼层
<p><font face="Verdana">'阿杰编写于:2009年8月22日21:26:26<br/>Private Sub Form_Load()<br/>&nbsp;&nbsp;&nbsp; Debug.Print max(100, 2, 15), min(100, 2, 15)<br/>End Sub</font></p>
<p><font face="Verdana">'取最大的数<br/>Function max(ParamArray 参数()) As Long<br/>&nbsp;&nbsp;&nbsp; If UBound(参数) &lt;&gt; -1 Then max = 参数(0)<br/>&nbsp;&nbsp;&nbsp; For i = 0 To UBound(参数)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If 参数(i) &gt; max Then max = 参数(i)<br/>&nbsp;&nbsp;&nbsp; Next<br/>End Function</font></p>
<p><font face="Verdana">'取最小的数<br/>Function min(ParamArray 参数()) As Long<br/>&nbsp;&nbsp;&nbsp; If UBound(参数) &lt;&gt; -1 Then min = 参数(0)<br/>&nbsp;&nbsp;&nbsp; For i = 0 To UBound(参数)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If 参数(i) &lt; min Then min = 参数(i)<br/>&nbsp;&nbsp;&nbsp; Next<br/>End Function</font></p>
<p><font face="Verdana"><br/></font>&nbsp;</p>
【VB】QQ群:1422505加的请打上VB好友
【易语言】QQ群:9531809  或 177048
【FOXPRO】QQ群:6580324  或 33659603
【C/C++/VC】QQ群:3777552
【NiceBasic】QQ群:3703755

30

主题

693

回帖

0

精华

钻石会员

积分
2815
发表于 2015-7-8 09:56:35 | 显示全部楼层
虽然乱码 内容还是不错的
您需要登录后才可以回帖 登录 | 加入我们

本版积分规则

快速回复 返回顶部 返回列表