Interaction between VBScript and ActiveX Control

This is a piece of code which shows the interaction between VBScript and ActiveX Control.

If you have a method in ActiveX Control which takes a Variant array to initiate the control for some purpose. Use this easy tip.

Step 1 :

In the ActiveX control say we have a function called AssignControlValues which takes the array of Variant values Declare the function like the following

Public Function AssignControlValues _
      (controlvalues As Variant)
dim controlarray as variant
dim maxvalues as integer
maxvalues  = UBound(controlvalues)
redim controlarray(maxvalues)
for i=0 to maxvalues 
next i
End function

Step 2 :

At the VBScript side

Declare the object 
<object classid="CLSID:XXXX" _
We can call the method in the ActiveX control from the VBScript using the Object ID just declared above

<script language="vbscript">
dim controlvalues
controlvalues(0)=text1.text    ' Assign values to the control array
controlvalues(1)=combo1.text   ' Either u get it from the HTML
                               ' Controls or anything else
call Object1.AssignControlValues controlvalues    ' pass the array
                                                  ' as variant
                                                  ' object
This way the user can pass the entire array with a single method call instead of passing with the ActiveX property. This is very usefull for the interaction between VBScript and ActiveX Control. Note : The method of object could be called with the values of elements in the ActiveX control also.


  • Syntans

    Posted by ZsiviraIndia on 11/19/2012 03:23am

    syntans manufacturers in india. Syntans are used for retanning of leather processing to produce leathers.

  • Properties are missing at ASP

    Posted by Legacy on 09/09/2003 12:00am

    Originally posted by: dwarakanadh

    this is dwarakanadh, i am finding difficulty regarding ocx control, any help is thankful.
    Problem Description:
    I created a ocx control, which it has only two text boxes. i want my control should have only one property that is "text" property of the one text box. i created property named "text" and delegated the text1.text property to that property.
    i was able to work with this ocx fine in VB.
    when i place this ocx control in asp page, i am finding that property listed under "Nil" category, because of that i am not able to use that property.
    any suggestions or solution is very thankful,

  • arrays problem

    Posted by Legacy on 12/13/2002 12:00am

    Originally posted by: rajesh

    te code is designed for problem as i cannot pass array to control error in asp page run time error mail me the solution

  • Made easy fro the others

    Posted by Legacy on 11/28/2002 12:00am

    Originally posted by: Peder Larsen

    Make an ocx control, name it TestCt, insert a textbox name: text1

    Insert this code:

    Public Function Test(ttt As String)
    Text1.Text = ttt
    End Function

    Then the HTML document:

    <OBJECT ID="TestCt"
    <script language="VBScript"><!--
    Sub Window_onLoad()
    With TestCt
    .Test "Now this works"
    End With
    End Sub

    Any questions! mail me =:-)

  • Passing params

    Posted by Legacy on 10/18/2002 12:00am

    Originally posted by: Domingos


    can i use the tag <param name="x1" value="value1">?

    how can i get the value in visual basic of th "x1 passed"?

    what are the declaration i must have?

    Thanks for your time

  • how to use this coe? i has problem.

    Posted by Legacy on 12/02/2001 12:00am

    Originally posted by: linn

    i can't running this code, how to use this code? 
    error, error, error~~~~

    please debug

  • Interaction between VBScript and ActiveX Control

    Posted by Legacy on 10/30/2001 12:00am

    Originally posted by: jembong

    In the code

    object classid="CLSID:XXXX" CODEBASE=

    Do you have to Register the OCX or not?
    What is CODEBASE?
    How can I use CODEBASE in an intranet application?

  • code problem

    Posted by Legacy on 08/18/2001 12:00am

    Originally posted by: preethy

    i want to know the object code for commomdialog box.

    <object classid="CLSID:XXXX" CODEBASE="">

    i want to know the correct syntax of this <OBJECT> tag and hte classid for commondialog.
    that is the full syntan.

    if possible please write back to me


Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Moving from an on-premises environment to Office 365 does not remove the need to plan for disruptions or reduce the business risk requirements for protecting email services. If anything, some risks increase with a move to the cloud. Read how to ease the transition every business faces if considering or already migrating to cloud email. This white paper discusses: Setting expectations when migrating to Office 365 Understanding the implications of relying solely on Exchange Online security Necessary archiving …

  • Anthony Christie, the Chief Marketing Officer for Level Communications, is responsible for customer experience, worldwide marketing and product management. In this informative asset, he shares his insights into why a private network connection to cloud-bases applications is the right decision for your enterprise. Download now to find out more.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date