Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How can you do a variable argument list in visual basic 6?

Posted on 2008-10-16
3
380 Views
Last Modified: 2010-10-05
In C you can declare a function like this

     int CombineArguments( int first, ... )

where the ellipses denote a variable argument list.

How can I do this in visual basic 6?

Tia,

- avi


0
Comment
Question by:progtw
3 Comments
 
LVL 7

Assisted Solution

by:FER_G
FER_G earned 40 total points
ID: 22731726
Tia,  avi;
Yes, in VB 6 you must use the PARAMARRAY word in the list of arguments; search in the msdn help file of vb
FerG
Saludos.
--
Ing. Fernando D. Giletta
San Fco. Cba. Argentina.
0
 
LVL 10

Assisted Solution

by:c0ldfyr3
c0ldfyr3 earned 40 total points
ID: 22731727
Like below, the only drawback is they have to be Variant.

Public Function CombineArguments(ParamArray vItem() As Variant) As Long
End Function

Open in new window

0
 
LVL 22

Accepted Solution

by:
danaseaman earned 45 total points
ID: 22731790
Try this:

Dim Res
Res = MyFunction("abc", 123, True, 4.5)

Private Function MyFunction(ParamArray args As Variant) 
   Dim i As Integer
 
   For i = LBound(args) To UBound(args)
      'do something
   Next i
End Function

Open in new window

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question