Cayetano Molina
Cayetano Molina

Reputation: 21

How to import a library from VBScript into another asp file using Jscript?

I'm Having trouble trying to import a library written in VBScript to another asp file written with Jscript. Im new to both script languages, however I was wondering if it was possible to cross-use both of them in one single file.

Right now I have the following code in my TestWebsite.asp file

<%@ Language="JavaScript" %>
<!--#include file="VBScriptClass.asp" -->
<html>
<head>
<title>File Upload</title>
</head>
<body>
<form id="fileUploadForm" name="fileUploadForm" action="TestWebsite.asp" enctype="multipart/form-data" method="post">
<input type="file" name="field5" id="field5" />
<input type="submit" value="Upload File">
</form>
<%
    var vbClass = Server.CreateObject("MyVBScriptClass")
    Response.Write(vbClass.GetMessage())
%>
 
has context menu
 
 

</body>
</html>

From what I understand the compiling of Jscript does need to be in order, however I've tried importing the library before and after using my Jscript and it is still giving me the same error.

Here is the code for the simple class in VBScriptClass.asp

<%
    Class MyVBScriptClass
        private message
        Public Sub Class_Initialize()
            message = "Hello World"
        End Sub
 
        Public Function GetMessage()
            GetMessage = message
        End Function
    End Class
%>

When I try running the code(starting the page) I'm getting the following error:

Microsoft JScript compilation error '800a03ec'
Expected ';'
/VBScriptClass.asp, line 2
Class MyVBScriptClass
------^

From what I understand it is probably an issue of how im using and importing libraries, however I do not know how to solve it. Just wanted to point out, this is using javascript as the default language and importing something from vbscript as the secondary language.

Upvotes: 0

Views: 35

Answers (0)

Related Questions