Solved

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

Posted on 2008-10-16
3
377 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article will show you how to use shortcut menus in the Access run-time environment.
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now