Solved

UDT and VBScript /Jscript

Posted on 1998-10-13
7
545 Views
Last Modified: 2012-06-22
I've written an ActiveX DLL with methods which use user defined types.

Is it possible to invoke these methods from VBscript or Jscript embedded in an HTML page?

Thanks
0
Comment
Question by:gdg60
7 Comments
 
LVL 2

Expert Comment

by:mitchell042997
ID: 1272145
I don't know if you can do it using an ActiveX DLL, but you can using an ActiveX control.  For the DLL, I would recommend using Active Server Pages script.  

You can find more information on my site, at:

   http://www.4guysfromrolla.com/webtech/091698-1.shtml

To do the ActiveX control, use the OBJECT tag in your HTML.  For example, say you created a DLL which had some structure as a private data member, and some method like, PrintStructure().  You could, in your HTML, do:

<OBJECT NAME="MyActiveXDLL" CLASSID="CLSID:........">
</OBJECT>

<SCRIPT LANGUAGE="JScript">
  document.MyActiveXDLL.PrintStructure();
</SCRIPT>

This is explained in more detail detail on my website.  (http://www.4GuysFromRolla.com).  Happy Programming!
0
 

Author Comment

by:gdg60
ID: 1272146
Probably I've not been very clear.

The problem is not how to call an object from an html page or an asp page, but if I can use, from VBscript or Jscript, a method that accepts a user defined type as parameter.

Example
myObject.MyMethod(par)
where par is a user defined type
Thanks .
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1272147
So what is a user defined type in this case?

Michel
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 

Author Comment

by:gdg60
ID: 1272148
Dear Michel

with VB6 you can write a demo class (clsDemo) like this.
-------
Public Type TestStru ' Create user-defined type.
   FieldA As Integer  
   FieldB As String
End Type


Public Sub PrintStructure(Struct As TestStru)
  MsgBox Struct.FieldA & " " & Struct.FieldB  
End Sub
--------
and then compile it to create an ActiveX DLL.

You can easily use this DLL from a VB or VC main.

...
...
dim str as TestStru
Dim b as clsDemo

..
str.fieldA = 1
str.fieldB = "Mickey Mouse"
..
b.PrintStructure str
..

and see the message box showing "1  Mickey Mouse"

My question is. Is it possible use the PrintStructure method from a VBScript or Jscript procedure ?

Thanks and Ciao from Italy

PS: Sorry for my english.. it's the best I can do


0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1272149
Sorry I have never seen it done.

if document.myActiveX.PrintStructure(2,'hello there'); does not work, I do not have any idea...
Cant you have
document.myActiveX.SetFieldA(2);
document.myActiveX.SetFieldB('Hello there');
document.myActiveX.CreateUDT('FieldA','FieldB');
document.myActiveX.PrintStructure();

Michel
0
 
LVL 10

Expert Comment

by:kollegov
ID: 1272150
I'm not sure for ActiveX, but I have some experience with Java applets methods envoking..
The problem is that JavaScript can pass set of simple parameters only,
allowed types are String, int and Float.
So you just can make wrappers for your methods which
create structure from a set of single parameters and pass it to your method.
I'm pretty sure this is the only way :(
0
 

Accepted Solution

by:
dtseng earned 20 total points
ID: 1272151
I think the quick answer is No.  What you may try doing is (edited text in CAPS):

      Public Type TestStru ' Create user-defined type.
         FieldA As Integer  
         FieldB As String
      End Type

      Public FUNCTION PrintStructure(Struct As TestStru) as String
        RETURN Struct.FieldA & " " & Struct.FieldB  
      End Sub
      --------
      and then compile it to create an ActiveX DLL.

      You can easily use this DLL from a VB or VC main.

      ...
      ...
      dim str as TestStru
      Dim b as clsDemo

      ..
      str.fieldA = 1
      str.fieldB = "Mickey Mouse"
      ..
      MSGBOX b.PrintStructure str
      ..
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

809 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