Solved

VBS - Copy Enumerations names and values into an array

Posted on 2004-04-21
1
212 Views
Last Modified: 2012-05-04
In VBS, I would like to use an Enumeration value in VBS without the worry of it changing with the next version of the DLL.  I have an example below of using the adUseClient Enumeration value with the Connection object.  I realize that Microsoft will not ever change adUseClinet from 3 to any other number, but other 3rd party objects may.

What I'm looking for is a workaround...  possibly storing Enumeration names and values in a multidimensional array, etc.  Any other thoughts and comments are encouraged.

'------------------------------
'this produces an error
'because of adUseClient
'------------------------------
dim ob
dim adUseClient

set ob = CreateObject("ADODB.Connection")
ob.Open "Provider=sqloledb;Data Source=dsd3dba;Integrated Security=SSPI"
ob.CursorLocation = adUseClient
set ob = Nothing
msgbox "done"
'------------------------------

Thank you.

Jessy Houle
0
Comment
Question by:jessy_houle
1 Comment
 
LVL 41

Accepted Solution

by:
graye earned 500 total points
ID: 10904718
So what you're asking for is a VBScript version of the standard "header files" (like the way C and C++ users are used to using).  

There isn't an official solution from Microsoft, but you could certainly build one yourself!   The newer WSF format for scripts supports an "include" directive.   You could then build a set of header files (based upon the C versions) and use them in your scripts.  If changes are required, a single change to the header would affect all of you script files.
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
why to use string 10 60
sum13 challenge 24 107
C# code editing and collaboration 3 118
Bartender label printing - switch on and off graphics 3 40
Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

831 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