When accessing the WIA members of a Vector object directly using the Vector Property or using the default property, they are visible to JScript as numbers:
var v = new ActiveXObject('WIA.Vector');
v.SetFromString('This is a test', true, false);
for (var i = 1; i<= v.Count; i+=1) {
WScript.Echo(String.fromCharCode(v(i)));
}
However, if I use Enumerator to iterate through Vector :
var enumerator = new Enumerator(v);
enumerator.moveFirst();
while (!enumerator.atEnd()) {
WScript.Echo(String.fromCharCode(enumerator.item()));
enumerator.moveNext();
}
The following error appears in WScript / CScript:
enumerator.item () is not a number
typeofreturns unknown:
WScript.Echo(typeof enumerator.item());
Presumably this is some kind of automation (as in this question ), which appears only as a number, therefore typeofreturns unknown.
How can I force this value to a "real" Javascript number?
Update
VBA:
Dim v As New Vector, item As Variant
v.SetFromString "This is a test", True, False
For Each item In v
Debug.Print TypeName(item)
Next
...
, .