Home > How-To Library > Coding Basics

How to accept any number of arguments in a function

**************************************************************** * © 2007 CodeItBetter http://www.codeitbetter.com * * This notice MUST stay intact for legal use * ****************************************************************
You can implement a routine that accepts any number of arguments using the ParamArray keyword Function Sum(ParamArray args() As Variant) As Double Dim I As Integer ' All ParamArrays are zero-based. For I = 0 To UBound(args) Sum = Sum + args(I) Next End Function

If you would like to submit your code here please us. Do not forget to mention your name. We are always thankful to each and everyone of you who submitted their code here.