Link to home
Start Free TrialLog in
Avatar of janeb
janeb

asked on

Setting value of an ActiveX control using PARAM

I am creating a control using VB5. How do I expose a variable whose value can be set in the HTML <OBJECT> tag using <PARAM>?
ASKER CERTIFIED SOLUTION
Avatar of v923146
v923146

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of janeb
janeb

ASKER

Sorry if I did not ask my question clearly !!
I know about the HTML part, I was actually asking how to expose the variable inside the VB5 codes of the control.
Hope this is clearer. Thanks!!
Make the variable a property of the control using Property Get and Property Let statements.  Then you'll be able to use it in the Param Name same as the others.

Syntax for Get

[Public | Private | Friend] [Static] Property Get name [(arglist)] [As type]
      [statements]
      [name = expression]
      [Exit Property]
      [statements]
      [name = expression]
End Property

Syntax for property Let

[Public | Private | Friend] [Static] Property Let name ([arglist,] value)
      [statements]
      [Exit Property]
      [statements]
End Property

Make the variable a property of the control using Property Get and Property Let statements.  Then you'll be able to use it in the Param Name same as the others.

Syntax for Get

[Public | Private | Friend] [Static] Property Get name [(arglist)] [As type]
      [statements]
      [name = expression]
      [Exit Property]
      [statements]
      [name = expression]
End Property

Syntax for property Let

[Public | Private | Friend] [Static] Property Let name ([arglist,] value)
      [statements]
      [Exit Property]
      [statements]
End Property

Avatar of janeb

ASKER

Hi thanks for the help.
But I tried it with no success, I did it like this:

In the General Declaration of VB5, I declare:
Private m_Value as Integer

In Property Let and Get:
Public Property Get My_Value() As Integer
    My_Value= m_Value
End Property

Public Property Let login_type(ByVal New_Value As Integer)
    m_Value = New_Value
End Property

In UserControl_Initialize of VB5, I use My_Value somewhere like this:
If My_Value = 1 Then.....

In HTML, I try to set My_Value in two ways like this:
( Using PARAM NAME )
<OBJECT ID="MyControl" .....>
<PARAM NAME="My_Value" VALUE="1">
</OBJECT>

( Using VBScript )
<HTML>
<HEAD>
Sub Window_onLoad()
   MyControl.My_Value = 1
End Sub
</Head>
...

When I run the control on my browser, the value of My_Value never gets set as 1, it remains as 0.
Would appreciate if you can tell me where I have gone wrong. Thanks !!!!

Avatar of janeb

ASKER

Sorry, in case it matters,
the last part on VBScript shd be:
( Using VBScript )
<HTML>
<HEAD>
<Script Language="VBScript">
<!--
Sub Window_onLoad()
   MyControl.My_Value = 1
End Sub
-->
</Script>
</Head>
...

Thanks!
Try this:

In the General Declaration of VB5, declare:
Private m_Value as Integer

In Property Let and Get:
Public Property Get My_Value() As Integer
 My_Value= m_Value
End Property

Public Property Let My_Value(ByVal vsMyValue As Integer)
  m_Value = vsMyValue
End Property

You have the HTML for the object right.  Let me know how this works out.
Avatar of janeb

ASKER

Yup it works. Thanks!!