Solved

UDT and VBScript /Jscript

Posted on 1998-10-13
7
558 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
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…

728 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