Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Microsoft VBScript compilation error '800a03f6'

Posted on 2004-10-25
12
Medium Priority
?
464 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
Comment
Question by:chadreeves1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
12 Comments
 
LVL 19

Expert Comment

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

Regards,
peh803
0
 
LVL 4

Expert Comment

by:LTY83
ID: 12404967
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
ID: 12405118
@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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 1

Author Comment

by:chadreeves1
ID: 12413878
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
ID: 12413913
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
ID: 12413950
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
ID: 12413974
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:
peh803 earned 360 total points
ID: 12413998
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
ID: 12414161
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
ID: 12414214
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
ID: 12414886
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
ID: 12414896
glad I could help!  
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

609 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