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

  • Employees must exchange sensitive emails with customers and partners. These emails might contain protected health information, protected financial information, or corporate information that should not be made public. Globalscape® Mail Express® allows you to encrypt the emails that it manages so that no one but the sender and recipient--not even the administrator--can view the contents of the email. "Secure the Transfer of Sensitive Emails" is the property of GlobalSCAPE

  • Enterprise endpoint backup can satisfy data collection and preservation requirements in a more streamlined and cost-effective manner than traditional e-discovery methods. Enterprise IT teams face increasing challenges as the amount of valuable data living on endpoints continues to grow. Due to the exploding volume, mobility and compliance requirements of enterprise data, the need to collect and preserve that data for the purpose of e-discovery becomes more critical--and more difficult. Traditionally, …

Most Popular Programming Stories

More for Developers

RSS Feeds

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