Call a function in ocx by using javascript

Posted on 2009-02-16
Last Modified: 2012-05-06
I have an ocx developed to retrieve hardware information. This ocx has a function (getInfo()) to return the obtained information in string.

I have a webpage (html) and I would like to call this getInfo() function by using javascript. However I failed and I receive a running error: Object doesn't support this property or method. It seems to me that I am not calling the function collectly. Would anyone help me please?
Function getInfo() in VB6

Public Function getInfo() As String


   Dim tmp As String, output As String  

   Call GetSystemInfo(SI)

   output = "Test Function"

   output = output & "SI.dwNumberOfProcessors: " & SI.dwNumberOfProcessors

   Select Case SI.dwProcessorType

      Case PROCESSOR_INTEL_386: tmp = "386"

      Case PROCESSOR_INTEL_486: tmp = "486"

      Case PROCESSOR_INTEL_PENTIUM: tmp = "Pentium"

      Case PROCESSOR_MIPS_R4000: tmp = "MIPS 4000"

      Case PROCESSOR_ALPHA_21064: tmp = "Alpha"

   End Select

   output = output & "SI.dwProcessorType & "" "" & tmp: " & SI.dwProcessorType & " " & tmp

   Select Case SI.wProcessorLevel

      Case PROCESSOR_LEVEL_80386: tmp = "Intel 80386"

      Case PROCESSOR_LEVEL_80486: tmp = "Intel 80486"

      Case PROCESSOR_LEVEL_PENTIUM: tmp = "Intel Pentium"

      Case PROCESSOR_LEVEL_PENTIUMII: tmp = "Intel Pentium Pro or Pentium II"

   End Select

   output = output & "SI.wProcessorLevel & "" "" & tmp: " & SI.wProcessorLevel & " " & tmp

   output = output & "SI.wProcessorRevision: " & SI.wProcessorRevision

   output = output & "GetCPUSpeed() & "" MHz"": " & GetCPUSpeed() & " MHz"

   getInfo = output

End Function

My html code




<script type="text/javascript" FOR="window">

function fn()






<body bgcolor=lightblue LANGUAGE = VBScript>

<!--	If any of the controls on this page require licensing, you must

	create a license package file. Run LPK_TOOL.EXE to create the

	required LPK file. LPK_TOOL.EXE can be found on the ActiveX SDK, If you have the Visual

	Basic 6.0 CD, it can also be found in the \Tools\LPK_TOOL directory.

	The following is an example of the Object tag:

<OBJECT CLASSID="clsid:5220cb21-c88d-11cf-b347-00aa00a28331">








CODEBASE="C:\Program Files\Microsoft Visual Studio\VB98\Package\myFirstOCX.ocx"








<INPUT TYPE=BUTTON VALUE=Textbox onclick="fn()" >




<INPUT TYPE=TEXT ID="ConnectionString" VALUE="" >



Open in new window

Question by:mishelper
    LVL 13

    Expert Comment

    hi ,

    use a <% tag %> and call the function

    b u d d h a

    Accepted Solution

    I found that the  function within activeX object cannot be called outside the ocx file. but they can be called by set/get property of the object.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: HTML5 Specialist

    HTML5 development skills are critical to all developers. HTML5 is the foundation to almost any development process. That's why business, design studios, development shops and other organizations need HTML5 developers. Get your foot in the door as a HTML5 specialist.

    Suggested Solutions

    Title # Comments Views Activity
    javascript error 8 34
    Effect on button 11 39
    PHP Radio Array 4 27
    appending location.reload to url with javascript 4 31
    "That which we persist in doing becomes easier, not that the task itself has become easier, but that our ability to perform it has improved." Ralph Waldo Emerson Introduction: One of the wonderful things about the web is that it makes it s…
    When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (, typical array handling might look like this: (CODE) B…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now