Solved

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

Posted on 2008-10-16
3
382 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
[X]
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
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

717 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