Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Can I access 64 bit integers through VBS?

1,172 views
Skip to first unread message

link...@gmail.com

unread,
Sep 25, 2012, 5:57:04 PM9/25/12
to
I have a COM DLL written in C++, and one of the methods returns a "long long*". When I call this method from a vb script I get the error "Microsoft VBScript runtime error: Variable uses an Automation type not supported in VBScript". I assume this is because VBScript doesn't have a 64 bit integer type. What are my options here? Is there ANY way I can have my C++ code return a 64bit integer to a VBScript?

This script illustrates my problem:
-----------------------------------------------
Dim instance
Set instance = CreateObject("LongLongTest.Test") ' This is my C++ COM dll

method is of type "long long*"
retVal = instance.GetLongLong(0, 2147483648)

MsgBox "Value returned = " & retVal
-----------------------------------------------

My C++ interface:
[id(1)] HRESULT GetLongLong([in] LONGLONG inputValue, [out] LONGLONG* outputValue, [out,retval] LONGLONG* RetVal);

Sidenote: My ultimate goal is to return a value to VBS for the second param (notice it's [out]), but I receive a different error when I pass in a variable -> "Type mismatch: 'GetLongLong'"

Thanks!

Dave "Crash" Dummy

unread,
Sep 25, 2012, 6:21:09 PM9/25/12
to
link...@gmail.com wrote:
> I have a COM DLL written in C++, and one of the methods returns a
> "long long*". When I call this method from a vb script I get the
> error "Microsoft VBScript runtime error: Variable uses an Automation
> type not supported in VBScript". I assume this is because VBScript
> doesn't have a 64 bit integer type. What are my options here? Is
> there ANY way I can have my C++ code return a 64bit integer to a
> VBScript?

The VBS engine is a 32 bit program. Integers are limited to -2^31 to 2^31-1
--
Crash

"In politics, stupidity is not a handicap."
~ Napoleon Bonaparte ~

Mayayana

unread,
Sep 25, 2012, 8:51:54 PM9/25/12
to
| The VBS engine is a 32 bit program. Integers are limited to -2^31 to
2^31-1

Integers are limited but one can return 1 trillion this way:

msgbox (1000000000 * 1000)

VBS is using variants, which can store large numbers.
And CDbl can convert to a Double. I don't know about a
function return that's returning a efined numeric datatype,
though.


link...@gmail.com

unread,
Sep 26, 2012, 8:03:35 AM9/26/12
to
I considered using double, but the loss of precision won't work for me. From what I understand, doubles can only store integers up to 2^53 accurately. I saw that Visual Basic has a Decimal data type, but it doesn't seem like this exists in VBS.

Mayayana

unread,
Sep 26, 2012, 9:24:08 AM9/26/12
to
| I considered using double, but the loss of precision won't work for me.
From what I understand, doubles can only store integers up to 2^53
accurately. I saw that Visual Basic has a Decimal data type, but it doesn't
seem like this exists in VBS.
|

Yes, that's an odd one. Decimal is recognized, but
while VB has a CDec method, VBS does not. While
VBS only recognizes variants, I can return a Long
from a DLL and it works. So I'm guessing the problem
may not be the size of the value but rather the
type. If Int64 is not an official COM data type then
it can't be converted to variant. You'll need to edit
your DLL to pass something to VBS that it can digest.


0 new messages