Solved

UDT and VBScript /Jscript

Posted on 1998-10-13
7
551 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
Industry Leaders: 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!

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

749 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