Re: Object Variable not set error

From: Tom Lavedas (tlavedas_at_hotmail.remove.com)
Date: 10/21/04


Date: Thu, 21 Oct 2004 09:39:06 -0700

The correct syntax is Exit Do, not exit loop.

Tom Lavedas
===========

"McKirahan" wrote:

> "Erica" <Erica@discussions.microsoft.com> wrote in message
> news:C4276A5D-6F28-470B-B149-C7B14B617A30@microsoft.com...
> > I'm getting this error:
> >
> > Microsoft VBScript runtime error '800a005b'
> >
> > Object variable not set
> >
> > /poll.asp, line 16
> >
> >
> > Here is my code:
> >
> > <%
> > if session("whois")="" then
> > response.Redirect("default.asp")
> > else
> > Set fs=Server.CreateObject("Scripting.FileSystemObject")
> > Set f=fs.OpenTextFile(Server.MapPath("voters.txt"), 1)
> >
> > do while f.AtEndOfStream = false
> > If f.readline = session("whois") then
> > AlreadyVoted = true
> > f.close
> > end if
> > loop
> >
> > If AlreadyVoted <> true then
> > Set f=fs.OpenTextFile(Server.MapPath("voters.txt"), 2)
> > f.writeline(session("whois"))
> > f.Close
> > Set f=Nothing
> > Set fs=Nothing
> > else
> > Set f=fs.OpenTextFile(Server.MapPath("voters.txt"), 2)
> > f.Close
> > Set f=Nothing
> > Set fs=Nothing
> > %>
> > <script language="JavaScript">
> > alert("The user currently logged in has already voted. If you are not the
> > user specified on the main page, log out and then login with your own
> > username and password.");
> > javascript:history.back();
> >
> > </script>
> > <%
> > end if
> >
> > Please help. Thank you all in advance for your help.
> >
>
> Just a guess after a quick review...
>
> do while f.AtEndOfStream = false
> If f.readline = session("whois") then
> AlreadyVoted = true
> f.close
> end if
> loop
>
> Try adding "exit loop" after "f.close" as you're trying to read a record
> after you closed the file.
>
>
>



Relevant Pages

  • Re: comparing values strange behaviour
    ... set field ... exit loop if ... exit loop if [ ... Changing the exit condition, I can't quite figure out what you're saying. ...
    (comp.databases.filemaker)
  • Re: do while: most elegant or efficient
    ... - is the do while faster or slower than a loop construct as described below. ... It doesn't matter whether this evaluation is before or after ... > complicated condition that doesn't fit the index intrinsic, ... > if exit loop ...
    (comp.lang.fortran)
  • [PATCH] balance_dirty_pages - exit loop when no more pages available
    ... exit loop in balance_dirty_pages when no more pages available to write ... On a bdi that has very little traffic balance_dirty_pages can loop ... this patch adds an extra exit condition to break out of the loop in this ...
    (Linux-Kernel)
  • Re: Exiting a for loop
    ... > I test the number and exception is thrown if there is an error. ... > How do I get the program to stop in the middle of the loop and go to the ... > Dim searcher As New ManagementObjectSearcher ... > WOULD LIKE TO EXIT LOOP HERE AND GO ON TO NEXT NUMBER ...
    (microsoft.public.dotnet.framework)
  • Re: Bringing IE to the foreground
    ... The code with the loop is the only one ... Gareth ... "Tom Lavedas" wrote in message ... > End With ' Shell ...
    (microsoft.public.scripting.vbscript)