Solved

Microsoft VBScript compilation error '800a03f6'

Posted on 2004-10-25
444 Views
Last Modified: 2008-02-01
I have been getting this error:

Microsoft VBScript compilation error '800a03f6'

Expected 'End'

/calendar/calendar.asp, line 215

When I open this code in a browser:

<%@LANGUAGE="VBSCRIPT"%>
<!--#include virtual="../DB/connection.asp" -->
<%
curDate = Date
If Request.QueryString("month") <> "" Then
curMonth = Request.QueryString("month")
Else
curMonth = Month(curDate)
End If
If Request.QueryString("year") <> "" Then
curYear = Request.QueryString("year")
Else
curYear = Year(Date)
End If
firstDayofMonth = WeekDay(DateSerial(curYear, curMonth, 1))
firstDayofMonthName = WeekDayName(WeekDay(DateSerial(Year(curDate), Month(curDate), 1)))
curMonthName = MonthName(curMonth)
If curMonth >= 12 Then
nxtMonth = 1
Else
nxtMonth = curMonth + 1
End If
nxtMonthName = MonthName(nxtMonth)
nxtYear = curYear + 1
lstDaylstMonth = Day(DateSerial(curYear, curMonth, 1-1))
lstDaylstMonthName = WeekDayName(WeekDay(lstDaylstMonth))
If curMonth = 1 Then
prvMonth = 12
Else
prvMonth = curMonth - 1
End If
prvMonthName = MonthName(prvMonth)
prvYear = curYear - 1

Select Case curMonth
Case 1,3,5,7,8,10,12
numDays = 31
Case 2
If curYear/4 = int(curYear/4) Then
numDays = 29
Else
numDays = 28
End If
Case 4,6,9,11
numDays = 30
End Select
i = 5
Function weeksInMonth(tmonth, tyear)
  lastDate = cDate(DateSerial(tYear, tMonth+1, 1-1))
  firstDate = cDate(tmonth&"/1/"&tYear)
  firstWeekNum = datePart("ww", firstDate)
  lastWeekNum = datePart("ww", lastDate)
  weeksInMonth = (1+(lastWeekNum-firstWeekNum))
end function
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title><%=curMonthName%> - <%=curYear%></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
img {
      border: none;
}
</style>
</head>
<body>
<table width="70%"  border="1" cellspacing="0" cellpadding="0">
  <!--DWLayoutTable-->
  <tr>
  <td colspan="7">
        <table border="0" width="100%">
              <tr>
        <td height="17" width="35"><a href="calendar.asp?month=<%=curMonth%>&year=<%=prvYear%>">
      <img src="images/p_year.gif" alt="Previous year:
<%=curMonthName%> - <%=prvYear%>" onMouseOver="this.src='images/p_year_over.gif'" onMouseOut="this.src='images/p_year.gif'">
      </a></td>
        <td height="17" width="35">
    <a href="calendar.asp?month=<%=prvMonth%><%      If curMonth = 1 Then      Response.Write("&year=" & prvYear)      Else      Response.Write("&year=" & curYear)      End If%>">
      <img src="images/p_month.gif" alt="Previous month:
<%=prvMonthName%> - <%If curMonth = 1 Then%><%=prvYear%><%Else%><%=curYear%><%End If%>" onMouseOver="this.src='images/p_month_over.gif'" onMouseOut="this.src='images/p_month.gif'">
      </a></td>
    <td align="center"><%=curMonthName%> - <%=curYear%></td>
      <td height="17" width="35">
    <a href="calendar.asp?month=<%=nxtMonth%>&year=<%      If curMonth = 12 Then      Response.Write(nxtYear)      Else      Response.Write(curYear)      End If      %>">
      <img src="Images/n_month.gif" alt="Next month:
<%=nxtMonthName%> - <%If curMonth = 12 Then%><%=nxtYear%><%Else%><%=curYear%><%End If%>" onMouseOver="this.src='Images/n_month_over.gif'" onMouseOut="this.src='Images/n_month.gif'">
      </a></td>
      <td height="17" width="35"><a href="calendar.asp?month=<%=curMonth%>&year=<%=nxtYear%>">
      <img src="Images/n_year.gif" alt="Next year:
<%=curMonthName%> - <%=nxtYear%>" onMouseOver="this.src='Images/n_year_over.gif'" onMouseOut="this.src='Images/n_year.gif'">
      </a></td>
      </tr>
  </table>
  </td>
  </tr>
  <tr>
    <td width="71">Sun</td>
    <td width="71">Mon</td>
    <td width="71">Tue</td>
    <td width="71">Wed</td>
    <td width="71">Thur</td>
    <td width="71">Fri</td>
    <td width="71">Sat</td>
  </tr>
      <%
      wInMonth = weeksInMonth(curMonth, curYear)
      For weeks = 1 to wInMonth
        %>
        <tr>
        <%
      If weeks = 1 Then
              For d = 1 to 7
                    If d < firstDayofMonth Then
                    %>
  <td bgcolor="#B9B9B9"><font color="#FF0000"><%=lstDaylstMonth - (firstDayofMonth - d)%></font>&nbsp;</td>
                  <%
                  Else
                  curDate = curMonth & "/" & (d*weeks)-((firstDayOfMonth-1)) & "/" & curYear
                    mDetailsSQL = "Select * from microlabs_details where micro_date = '" & curDate & "'"
                    Dim mDetails
                    Set mDetails = Server.CreateObject("ADODB.Recordset")
                    mDetails.ActiveConnection = conn.ConnectionString
                    mDetails.Source = mDetailsSQL
                    mDetails.CursorLocation = 3
                    mDetails.Open
                  %>
  <td><%=(d*weeks)-(firstDayOfMonth-1)%>
                  <%
                  mRC = mDetails.RecordCount
                        If mRC > 0 Then
                        %>
  <p><%=mDetails.RecordCount%> Microlab<% If mRC > 1 Then%>s<%Else%><%End If%></td>
                        <%
                        Else
                        %>
  <p></td>
                        <%
                        End If
                  mDetails.Close
                  Set mDetails = Nothing
                  End If
            Next
            %>
  </tr>
            <%
      Else If 1 < weeks < wInMonth Then
            For d = 1 to 7
            curDate = curMonth & "/" & d+((weeks-1)*7) & "/" & curYear
              mDetailsSQL = "Select * from microlabs_details where micro_date = '" & curDate & "'"
              Set mDetails = Server.CreateObject("ADODB.Recordset")
              mDetails.ActiveConnection = conn.ConnectionString
              mDetails.Source = mDetailsSQL
              mDetails.CursorLocation = 3
              mDetails.Open
            %>
  <td><%=d+((weeks-1)*7)%>
            <%
            mRC = mDetails.RecordCount
                  If mRC > 0 Then
                  %>
  <p><%=mDetails.RecordCount%> Microlab<% If mRC > 1 Then%>s<%Else%><%End If%></td>
                  <%
                  Else
                  %>
  <p></td>
                  <%
                  End If
            mDetails.Close
            Set mDetails = Nothing
            Next
            %>
  </tr>
            <%
            Else If weeks = wInMonth Then
                  For d = 1 to 7
                        If (d+((weeks-1)*7)) <= numDays Then
                        curDate = curMonth & "/" & d+((weeks-1)*7) & "/" & curYear
                          mDetailsSQL = "Select * from microlabs_details where micro_date = '" & curDate & "'"
                          Set mDetails = Server.CreateObject("ADODB.Recordset")
                          mDetails.ActiveConnection = conn.ConnectionString
                          mDetails.Source = mDetailsSQL
                          mDetails.CursorLocation = 3
                          mDetails.Open
                        %>
  <td><%=d+((weeks-1)*7)%>
                        <%
                        mRC = mDetails.RecordCount
                        If mRC > 0 Then
                        %>
  <p><%=mDetails.RecordCount%> Microlab<% If mRC > 1 Then%>s<%Else%><%End If%></td>
                        <%
                        Else
                        %>
  <p></td>
                        <%
                        End If
                  mDetails.Close
                  Set mDetails = Nothing
                  Else
                  %>
  <td bgcolor="#B9B9B9"><font color="#FF0000"><%=d-(d-1)%></font>&nbsp;</td>
                  <%
                  End If
            Next
            End If
      %>
</tr>
</table>
</body>
</html>

I know this is a lot to ask for as little points as I am offering, however when I accept your answer I will give you as many points as I have.

Thank you,
chadreeves1
0
Question by:chadreeves1
    12 Comments
     
    LVL 19

    Expert Comment

    by:peh803
    Else If should be "elseif" (no space)

    Regards,
    peh803
    0
     
    LVL 4

    Expert Comment

    by:LTY83
    looks like you are missing an End If here:

         <%
              Else If weeks = wInMonth Then
                   For d = 1 to 7
                        If (d+((weeks-1)*7)) <= numDays Then
                        curDate = curMonth & "/" & d+((weeks-1)*7) & "/" & curYear
                          mDetailsSQL = "Select * from microlabs_details where micro_date = '" & curDate & "'"
                          Set mDetails = Server.CreateObject("ADODB.Recordset")
                          mDetails.ActiveConnection = conn.ConnectionString
                          mDetails.Source = mDetailsSQL
                          mDetails.CursorLocation = 3
                          mDetails.Open
                        %>
      <td><%=d+((weeks-1)*7)%>
                        <%
                        mRC = mDetails.RecordCount

    'END IF NEEDS TO COME BEFORE THIS

                        If mRC > 0 Then
                        %>
    0
     
    LVL 19

    Expert Comment

    by:peh803
    @chadreeves1:

    Did you try changing all occurrences of "else if" to "elseif"?

    This (perhaps in addition to what LTY83 said, I haven't checked it) should fix your issue.

    Thanks,
    peh803
    0
     
    LVL 1

    Author Comment

    by:chadreeves1
    LTY83 - I see what you are saying and the end if that you are refering to is at the bottom of the script shown below.

    peh803 - I tried that and it is saying that i need the "elseif" to be "else if".

    <code>
                        If (d+((weeks-1)*7)) <= numDays Then
                        curDate = curMonth & "/" & d+((weeks-1)*7) & "/" & curYear
                          mDetailsSQL = "Select * from microlabs_details where micro_date = '" & curDate & "'"
                          Set mDetails = Server.CreateObject("ADODB.Recordset")
                          mDetails.ActiveConnection = conn.ConnectionString
                          mDetails.Source = mDetailsSQL
                          mDetails.CursorLocation = 3
                          mDetails.Open
                        %>
      <td><%=d+((weeks-1)*7)%>
                        <%
                        mRC = mDetails.RecordCount
                        If mRC > 0 Then
                        %>
      <p><%=mDetails.RecordCount%> Microlab<% If mRC > 1 Then%>s<%Else%><%End If%></td>
                        <%
                        Else
                        %>
      <p></td>
                        <%
                        End If
    </code>
    0
     
    LVL 19

    Expert Comment

    by:peh803
    in vbscript, "else if" (with the space) is incorrect.  Regardless if what "it" is telling you, the proper way to write vbscript / ASP if / then / else statements is this:

    If condition1="1" then
      ' handle condition 1
    elseif condition2 = "2" then
      ' handle condition 2
    else
      ' handle all other cases
    end if

    This is surely the problem.
    peh803
    0
     
    LVL 1

    Author Comment

    by:chadreeves1
    I also wanted to thank you for looking at my code for the little points that i have.
    0
     
    LVL 19

    Expert Comment

    by:peh803
    of course, no problem.  Don't worry about points. I just want to help you solve your problem!

    :-)

    peh803
    0
     
    LVL 19

    Accepted Solution

    by:
    Here's your code.  all I've done is replaced the two "else if" statements in your code with "elseif"

    Please try executing this on the page, and if you do receive an error, please let me know what it is.

    Thanks,
    peh803

    <%@LANGUAGE="VBSCRIPT"%>
    <!--#include virtual="../DB/connection.asp" -->
    <%
    curDate = Date
    If Request.QueryString("month") <> "" Then
    curMonth = Request.QueryString("month")
    Else
    curMonth = Month(curDate)
    End If
    If Request.QueryString("year") <> "" Then
    curYear = Request.QueryString("year")
    Else
    curYear = Year(Date)
    End If
    firstDayofMonth = WeekDay(DateSerial(curYear, curMonth, 1))
    firstDayofMonthName = WeekDayName(WeekDay(DateSerial(Year(curDate), Month(curDate), 1)))
    curMonthName = MonthName(curMonth)
    If curMonth >= 12 Then
    nxtMonth = 1
    Else
    nxtMonth = curMonth + 1
    End If
    nxtMonthName = MonthName(nxtMonth)
    nxtYear = curYear + 1
    lstDaylstMonth = Day(DateSerial(curYear, curMonth, 1-1))
    lstDaylstMonthName = WeekDayName(WeekDay(lstDaylstMonth))
    If curMonth = 1 Then
    prvMonth = 12
    Else
    prvMonth = curMonth - 1
    End If
    prvMonthName = MonthName(prvMonth)
    prvYear = curYear - 1

    Select Case curMonth
    Case 1,3,5,7,8,10,12
    numDays = 31
    Case 2
    If curYear/4 = int(curYear/4) Then
    numDays = 29
    Else
    numDays = 28
    End If
    Case 4,6,9,11
    numDays = 30
    End Select
    i = 5
    Function weeksInMonth(tmonth, tyear)
      lastDate = cDate(DateSerial(tYear, tMonth+1, 1-1))
      firstDate = cDate(tmonth&"/1/"&tYear)
      firstWeekNum = datePart("ww", firstDate)
      lastWeekNum = datePart("ww", lastDate)
      weeksInMonth = (1+(lastWeekNum-firstWeekNum))
    end function
    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title><%=curMonthName%> - <%=curYear%></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    img {
         border: none;
    }
    </style>
    </head>
    <body>
    <table width="70%"  border="1" cellspacing="0" cellpadding="0">
      <!--DWLayoutTable-->
      <tr>
      <td colspan="7">
           <table border="0" width="100%">
                <tr>
           <td height="17" width="35"><a href="calendar.asp?month=<%=curMonth%>&year=<%=prvYear%>">
         <img src="images/p_year.gif" alt="Previous year:
    <%=curMonthName%> - <%=prvYear%>" onMouseOver="this.src='images/p_year_over.gif'" onMouseOut="this.src='images/p_year.gif'">
         </a></td>
           <td height="17" width="35">
        <a href="calendar.asp?month=<%=prvMonth%><%     If curMonth = 1 Then     Response.Write("&year=" & prvYear)     Else     Response.Write("&year=" & curYear)     End If%>">
         <img src="images/p_month.gif" alt="Previous month:
    <%=prvMonthName%> - <%If curMonth = 1 Then%><%=prvYear%><%Else%><%=curYear%><%End If%>" onMouseOver="this.src='images/p_month_over.gif'" onMouseOut="this.src='images/p_month.gif'">
         </a></td>
        <td align="center"><%=curMonthName%> - <%=curYear%></td>
         <td height="17" width="35">
        <a href="calendar.asp?month=<%=nxtMonth%>&year=<%     If curMonth = 12 Then     Response.Write(nxtYear)     Else     Response.Write(curYear)     End If     %>">
         <img src="Images/n_month.gif" alt="Next month:
    <%=nxtMonthName%> - <%If curMonth = 12 Then%><%=nxtYear%><%Else%><%=curYear%><%End If%>" onMouseOver="this.src='Images/n_month_over.gif'" onMouseOut="this.src='Images/n_month.gif'">
         </a></td>
         <td height="17" width="35"><a href="calendar.asp?month=<%=curMonth%>&year=<%=nxtYear%>">
         <img src="Images/n_year.gif" alt="Next year:
    <%=curMonthName%> - <%=nxtYear%>" onMouseOver="this.src='Images/n_year_over.gif'" onMouseOut="this.src='Images/n_year.gif'">
         </a></td>
         </tr>
      </table>
      </td>
      </tr>
      <tr>
        <td width="71">Sun</td>
        <td width="71">Mon</td>
        <td width="71">Tue</td>
        <td width="71">Wed</td>
        <td width="71">Thur</td>
        <td width="71">Fri</td>
        <td width="71">Sat</td>
      </tr>
         <%
         wInMonth = weeksInMonth(curMonth, curYear)
         For weeks = 1 to wInMonth
           %>
           <tr>
           <%
         If weeks = 1 Then
                For d = 1 to 7
                     If d < firstDayofMonth Then
                     %>
      <td bgcolor="#B9B9B9"><font color="#FF0000"><%=lstDaylstMonth - (firstDayofMonth - d)%></font>&nbsp;</td>
                   <%
                   Else
                   curDate = curMonth & "/" & (d*weeks)-((firstDayOfMonth-1)) & "/" & curYear
                     mDetailsSQL = "Select * from microlabs_details where micro_date = '" & curDate & "'"
                     Dim mDetails
                     Set mDetails = Server.CreateObject("ADODB.Recordset")
                     mDetails.ActiveConnection = conn.ConnectionString
                     mDetails.Source = mDetailsSQL
                     mDetails.CursorLocation = 3
                     mDetails.Open
                   %>
      <td><%=(d*weeks)-(firstDayOfMonth-1)%>
                   <%
                   mRC = mDetails.RecordCount
                        If mRC > 0 Then
                        %>
      <p><%=mDetails.RecordCount%> Microlab<% If mRC > 1 Then%>s<%Else%><%End If%></td>
                        <%
                        Else
                        %>
      <p></td>
                        <%
                        End If
                   mDetails.Close
                   Set mDetails = Nothing
                   End If
              Next
              %>
      </tr>
              <%
         ElseIf 1 < weeks < wInMonth Then
              For d = 1 to 7
              curDate = curMonth & "/" & d+((weeks-1)*7) & "/" & curYear
                mDetailsSQL = "Select * from microlabs_details where micro_date = '" & curDate & "'"
                Set mDetails = Server.CreateObject("ADODB.Recordset")
                mDetails.ActiveConnection = conn.ConnectionString
                mDetails.Source = mDetailsSQL
                mDetails.CursorLocation = 3
                mDetails.Open
              %>
      <td><%=d+((weeks-1)*7)%>
              <%
              mRC = mDetails.RecordCount
                   If mRC > 0 Then
                   %>
      <p><%=mDetails.RecordCount%> Microlab<% If mRC > 1 Then%>s<%Else%><%End If%></td>
                   <%
                   Else
                   %>
      <p></td>
                   <%
                   End If
              mDetails.Close
              Set mDetails = Nothing
              Next
              %>
      </tr>
              <%
              ElseIf weeks = wInMonth Then
                   For d = 1 to 7
                        If (d+((weeks-1)*7)) <= numDays Then
                        curDate = curMonth & "/" & d+((weeks-1)*7) & "/" & curYear
                          mDetailsSQL = "Select * from microlabs_details where micro_date = '" & curDate & "'"
                          Set mDetails = Server.CreateObject("ADODB.Recordset")
                          mDetails.ActiveConnection = conn.ConnectionString
                          mDetails.Source = mDetailsSQL
                          mDetails.CursorLocation = 3
                          mDetails.Open
                        %>
      <td><%=d+((weeks-1)*7)%>
                        <%
                        mRC = mDetails.RecordCount
                        If mRC > 0 Then
                        %>
      <p><%=mDetails.RecordCount%> Microlab<% If mRC > 1 Then%>s<%Else%><%End If%></td>
                        <%
                        Else
                        %>
      <p></td>
                        <%
                        End If
                   mDetails.Close
                   Set mDetails = Nothing
                   Else
                   %>
      <td bgcolor="#B9B9B9"><font color="#FF0000"><%=d-(d-1)%></font>&nbsp;</td>
                   <%
                   End If
              Next
              End If
         %>
    </tr>
    </table>
    </body>
    </html>
    0
     
    LVL 1

    Author Comment

    by:chadreeves1
    Allright what did you do and where?

    It created a calendar. There are two many weeks and the dates go up to 42 but it got threw.

    I got an error off of your code, it needed a next on line 206. After i put the next in it work (sort of)!!!
    0
     
    LVL 19

    Expert Comment

    by:peh803
    all I did was exactly what I said I did.  I replaced the "else if" statements with "elseif".

    This is exactly what I've been telling you to do from the beginning.

    There are two "elseif" statements in your code.  Those are the ones I fixed.  I don't know how to be more clear than this.

    Regards,
    peh803
    0
     
    LVL 1

    Author Comment

    by:chadreeves1
    Ok I see know It took me a while to find what you were talking about.

    Thank you for your efforts in this problem,
    chadreeves1
    0
     
    LVL 19

    Expert Comment

    by:peh803
    glad I could help!  
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Anonabox PRO Tor & VPN Router

    PRO is the most advanced way to fortify your privacy and online anonymity by layering the Tor network with VPN services. Use both together or separately, and without needing to download software onto your devices.

    I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
    I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
    This video is in connection to the article "The case of a missing mobile phone (https://www.experts-exchange.com/articles/28474/The-Case-of-a-Missing-Mobile-Phone.html)". It will help one to understand clearly the steps to track a lost android phone.
    Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    857 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

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now