Solved

Setting value of an ActiveX control using PARAM

Posted on 1998-01-20
8
214 Views
Last Modified: 2009-07-29
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>?
0
Comment
Question by:janeb
  • 4
  • 4
8 Comments
 

Accepted Solution

by:
v923146 earned 50 total points
ID: 1452556
Here's an example of one I wrote:

<OBJECT ID="Label1" WIDTH=50 HEIGHT=20 NOTAB
 CLASSID="CLSID:978C9E23-D4B0-11CE-BF2D-00AA003F40D0">
                                                 <PARAM NAME="ForeColor" VALUE="<%=fColor%>">
<PARAM NAME="BackColor" VALUE="12632256">
<PARAM NAME="Caption" VALUE="<%=iUsage%>">
<PARAM NAME="Size" VALUE="2540;635">
<PARAM NAME="FontEffects" VALUE="1073741825">
<PARAM NAME="FontHeight" VALUE="280">
<PARAM NAME="FontCharSet" VALUE="0">
<PARAM NAME="FontPitchAndFamily" VALUE="2">
<PARAM NAME="ParagraphAlign" VALUE="3">
<PARAM NAME="FontWeight" VALUE="700">

</OBJECT>

Hope this helps.



0
 

Author Comment

by:janeb
ID: 1452557
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!!
0
 

Expert Comment

by:v923146
ID: 1452558
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

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:v923146
ID: 1452559
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

0
 

Author Comment

by:janeb
ID: 1452560
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 !!!!

0
 

Author Comment

by:janeb
ID: 1452561
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!
0
 

Expert Comment

by:v923146
ID: 1452562
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.
0
 

Author Comment

by:janeb
ID: 1452563
Yup it works. Thanks!!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

679 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