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 
controlarray(i)=controlvalues(i)
next i
End function

Step 2 :

At the VBScript side


Declare the object 
<object classid="CLSID:XXXX" _
       CODEBASE="http://vbsource/object.CAB#Version=2,0,0,0
id="Object1>
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
controlvalues(2)=text3.text
controlvalues(3)=list1.name
controlvalues(4)=text1.text
 
call Object1.AssignControlValues controlvalues    ' pass the array
                                                  ' as variant
                                                  ' object
 
</script>
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.


Comments

  • 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.

    Reply
  • Properties are missing at ASP

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

    Originally posted by: dwarakanadh

    Hi,
    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,
    regards,
    dwaraka.

    Reply
  • 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

    Reply
  • 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:

    <HTML>
    <HEAD>
    <TITLE>Project1.CAB</TITLE>
    </HEAD>
    <BODY>
    <OBJECT ID="TestCt"
    CLASSID="CLSID:94426FCE-9BBD-48A9-B7A5-1E6922606195"
    CODEBASE="Project1.CAB#version=1,0,0,0">
    </OBJECT>
    </BODY>
    </HTML>
    <script language="VBScript"><!--
    Sub Window_onLoad()
    With TestCt
    .Test "Now this works"
    End With
    End Sub
    --></script>

    Any questions! mail me =:-)

    Reply
  • Passing params

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

    Originally posted by: Domingos

    Hi!

    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

    Reply
  • 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

    Reply
  • 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?


    Reply
  • 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


    bye

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

Top White Papers and Webcasts

  • Live Event Date: December 11, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT Market pressures to move more quickly and develop innovative applications are forcing organizations to rethink how they develop and release applications. The combination of public clouds and physical back-end infrastructures are a means to get applications out faster. However, these hybrid solutions complicate DevOps adoption, with application delivery pipelines that span across complex hybrid cloud and non-cloud environments. Check out this …

  • With the average hard drive now averaging one terabyte in size, the fallout from the explosion of user-created data has become an overwhelming volume of potential evidence that law-enforcement and corporate investigators spend countless hours examining. Join Us and SANS' Rob Lee for our 45-minute webinar, A Triage and Collection Strategy for Time-Sensitive Investigations, will demonstrate how to: Identify the folders and files that often contain key insights Reduce the time spent sifting through content by …

Most Popular Programming Stories

More for Developers

RSS Feeds