0

I am developing an ActiveX control for IE which is invoked through javascript. The ActiveX control is developed in visual basic and it has an array of strings. How will I use this array of strings in javascript.

Eg :-

var a = new Array()
a = objActiveX.GetArray(); // call to active x returns array of string, how will I loop through this in javascript. 

The above line does not work. I want to loop through each string in javascript.

Advise.

1
  • 1
    need some more info. what "doesn't work"? what do you get with 'alert("a:" + a);"? Commented Dec 7, 2010 at 2:17

2 Answers 2

1

Usually, arrays returned from COM/OLE/ActiveX components are SAFEARRAYs. There's a special object in JScript called VBArray that adapts between the two.

See http://blogs.msdn.com/b/david.wang/archive/2006/07/04/howto-convert-between-jscript-array-and-vb-safe-array.aspx for a good example of going back and forth between JavaScript arrays and SAFEARRAYs.

More detailed info on VBArray here: http://msdn.microsoft.com/en-us/library/3s0fw3t2(VS.80).aspx

Note that this is part of JScript -- I'm not 100% sure that IEs default scripting runtime is JScript, but I think so.

Sign up to request clarification or add additional context in comments.

Comments

1

This function will convert a multi-dimensional VB safe-array into a multi-dimensional javascript array.

Try it out, Let me know if you can break it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.