Solved

how to pass in a list of string/numbers into a vbs function

Posted on 2013-01-23
1
443 Views
Last Modified: 2013-01-23
I have the following vbs function that accepts a parameter array

Function TEST(Arr())
   k=ubound(Arr)
   msgbox(k)
End Function

The calling function in this system is dynamically generated as a string and then a msscript control invokes it.

How can I call the function and pass in the array by init its values as a string using the following syntax?

Dim numbers = New Integer() {1, 2, 4, 8}
Dim doubles = {1.5, 2, 9.9, 18}

Example:

TEST({1,2,3,4}) '<--how can i pass these in as literals?
0
Comment
Question by:glenn_r
1 Comment
 
LVL 52

Accepted Solution

by:
Bill Prew earned 265 total points
ID: 38811330
Here is the correct VBS syntax:

TEST(Array(1,2,3,4))

Function TEST(Arr())
   k=ubound(Arr)
   msgbox(k)
End Function

Open in new window

~bp
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

895 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

12 Experts available now in Live!

Get 1:1 Help Now