Microsoft VBScript compilation error '800a03f6'

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
LVL 1
chadreeves1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

peh803Commented:
Else If should be "elseif" (no space)

Regards,
peh803
0
LTY83Commented:
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
peh803Commented:
@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
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

chadreeves1Author Commented:
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
peh803Commented:
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
chadreeves1Author Commented:
I also wanted to thank you for looking at my code for the little points that i have.
0
peh803Commented:
of course, no problem.  Don't worry about points. I just want to help you solve your problem!

:-)

peh803
0
peh803Commented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
chadreeves1Author Commented:
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
peh803Commented:
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
chadreeves1Author Commented:
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
peh803Commented:
glad I could help!  
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.