Hello,

I would like to know how to use a COM object's enum in VBScript?

For example:

Set objCN = CreateObject("ADODB.Connection")
'objCN.CursorLocation = adUseClient

Note that "adUseClient" is an enum (ADODB.CursorLocationEnum.adUseClient).

Thanks a lot.

Sa

Re: Using COM object's enum by Michael

Michael
Thu Jan 06 11:49:49 CST 2005

Sa wrote:
> Hello,
>
> I would like to know how to use a COM object's enum in VBScript?


What is the host environment for the script? ASP? WSH? ???

Server side ASP and WSH (WSF file format) both have mechanisms to expose
named constants from type libraries...


>
> For example:
>
> Set objCN = CreateObject("ADODB.Connection")
> 'objCN.CursorLocation = adUseClient
>
> Note that "adUseClient" is an enum
> (ADODB.CursorLocationEnum.adUseClient).
>
> Thanks a lot.
>
> Sa

--
Michael Harris
Microsoft.MVP.Scripting


Re: Using COM object's enum by Sa

Sa
Thu Jan 06 20:05:10 CST 2005

Thanks for your answer.

In fact, the host environment is not ASP nor WSH. We are doing
customization for a product which require VBScript for coding. However, we
need to use "ADODB.Connection", "ADODB.Recordset", .... and other COM
objects.

May I know how to do it in ASP and WSH environment?

Thanks a lot.

Sa


"Michael Harris (MVP)" <mikhar@mvps.org> wrote in message
news:OJNFfgB9EHA.2600@TK2MSFTNGP09.phx.gbl...
> Sa wrote:
> > Hello,
> >
> > I would like to know how to use a COM object's enum in VBScript?
>
>
> What is the host environment for the script? ASP? WSH? ???
>
> Server side ASP and WSH (WSF file format) both have mechanisms to expose
> named constants from type libraries...
>
>
> >
> > For example:
> >
> > Set objCN = CreateObject("ADODB.Connection")
> > 'objCN.CursorLocation = adUseClient
> >
> > Note that "adUseClient" is an enum
> > (ADODB.CursorLocationEnum.adUseClient).
> >
> > Thanks a lot.
> >
> > Sa
>
> --
> Michael Harris
> Microsoft.MVP.Scripting
>



Re: Using COM object's enum by mr

mr
Fri Jan 07 16:49:13 CST 2005

hi Sa,

The reason mikHar asked about the host is that there are standard
methods for making typelib enummed constants available to script
code in IE or wsh hosted scripts. That is, object tags and reference
tags.

It sounds like you are using a script control to add scripting to your
app, and unfortunately there is no standard way to include a typelib
in a script control hosted script.

Therefore you are going to have to resort to "magic".

In this instance, the definition of "magic" is: "If you want to pull a
rabbit out of the hat, you first have to put the rabbit into the hat".

In other words, you are going to have to pre-define the constants
you wish to make available to your users, and place those constants
in a "module".

Presumably, your users are going to be writing their script code in a
multiline textbox (or something similiar), and you app will then take the
code and insert it into the script control.

Along with the users code, I am suggesting that you also insert your
module with the predefined constants you wish to make available to
your users into the script control, giving the module with the constants
"global scope" (i.e., the constants will then be available to any code
entered in the script control.

That should to it.

cheers, jw

"Sa" <ksadf@sdkaew.org> wrote in message
news:eC4b6798EHA.2196@TK2MSFTNGP11.phx.gbl...
> Hello,
>
> I would like to know how to use a COM object's enum in VBScript?
>
> For example:
>
> Set objCN = CreateObject("ADODB.Connection")
> 'objCN.CursorLocation = adUseClient
>
> Note that "adUseClient" is an enum (ADODB.CursorLocationEnum.adUseClient).
>
> Thanks a lot.
>
> Sa
>
>