Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

object or with variable not set error?

Status
Not open for further replies.

hinchdog

Programmer
Feb 14, 2001
380
US
I have a test program that is using a .dll i created. it works find when i access it form the program, like so:

Dim IE As HTMLParser.IE
Set IE = CreateObject("HTMLParser.IE")

txtResults.Text = IE.GetRequest(testvalue, testvalue)

This works find and puts the results in a textbox. Now, when I try to use the .dll from a webpage using jscript, i get the error "Object variable or With block variable not set" using the code below..

var IE = Server.CreateObject("HTMLParser.IE");
var result = IE.GetRequest(testvalue,testvalue);

what the heck am i doing wrong?
 
I think you should use the statement like this to create an object from the class in JScript(or JavaScript):

var var_name = new class_name;
 
wish it were that simple. i think it has something to do with MTS and running dll's in a transaction. I'm finding this is not so easy to do with PWS. i let you know if i ever get this thing working.
 
Take a look at this code. It is a changed version of my .asp page, which creates object from dll written by me.
It seems to work in general: creates object with javascript.
I commented vbscript statements to show the differences in declarations and usage of object variable:


<%@language=javascript%>
<html>
<head>
<title>Untitled</title>

</head>

<body>
<%
var stu;
stu = new ActiveXObject(&quot;Student.clsStudent&quot;);
var blnResult = false;
//set stu = server.CreateObject(&quot;Student.clsStudent&quot;)
//with stu
stu.StudentID = Request(&quot;StudentID&quot;);
stu.FName = Request.Form(&quot;FName&quot;);
stu.LName = Request.Form(&quot;LName&quot;);
stu.Course = Request.Form(&quot;Course&quot;);
stu.Payment = Request.Form(&quot;Payment&quot;);
stu.PaymentDone = Request.Form(&quot;PaymentDone&quot;);
//end with
blnResult = stu.Save();
if (blnResult) // = true then
Response.Write(&quot;<h2>Success!!!<br>Your information has
been added for processing!</h2>&quot;);
else
Response.Write(&quot;<h2>Operation failed!<br>Press 'Back'
button of your browser and try again. If the error
persists, call technical support!</h2>&quot;);
//end if
stu = null;//set stu = nothing

%>
</body>
</html>


At least, it doesn't give me a familiar error message.
Try to use the same approach and see what happens.

By the way, here's the link to the article, which helped to find the right syntax:
 
hi,

i am also facing the same problem. i wish to invoke a dll which is created in vb using active server pages library. even this simple component is not working, i am getting error. codings are given below. let me know how to solve. if u have some good samples please send me thr' mail. i will be helpful.

VB Coding

project name: car
class name: mycar

Private MyResponse As Response

Public Sub ProcessForm()
Dim strForm
strForm = &quot;<form name=frmCar action=MyCar.asp?qs=1 method=post>&quot;
strForm = strForm & &quot;Name: <input type=text name=txtName><BR>&quot;
strForm = strForm & &quot;Model: <input type=text name=txtModel><BR>&quot;
strForm = strForm & &quot;Color: <input type=text name=txtColor><BR>&quot;
strForm = strForm & &quot;Price: <input type=text name=txtPrice><BR>&quot;
strForm = strForm & &quot;<input type=submit value=Submit><BR>&quot;
strForm = strForm & &quot;</form>&quot;
MyResponse.Write (strForm)
End Sub

after compiled this program into a dll i called in asp using the following code. but i am getting an error if i run that asp file.


ASP Coding

<%
dim objCar
Set ObjCar = Server.CreateObject(&quot;Car.MyCar&quot;)
objCar.ProcessForm
%>


the error message is:
Car error '800a005b'
Object variable or With block variable not set
/portal/lenin/mycom/MyCar.asp, line 7

bye
lenin
 
If u want to use the object in your server side script you could use ActiveXObject or Server.CreateObject but u need to put the &quot;new&quot; word to your sintax:

var IE = new ActiveXObject(&quot;HTMLParser.IE&quot;);
var IE = new Server.CreateObject(&quot;HTMLParser.IE&quot;);

Personally i use the seccond one in my asp pages...
<%@ LANGUAGE=JSCRIPT %>
<%
var IE = new Server.CreateObject(&quot;HTMLParser.IE&quot;);
%>
... ________

George
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top