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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please Explain This Error

Status
Not open for further replies.

arpan

Programmer
Oct 16, 2002
336
IN
Consider the following ASP code snippet:

<%
Dim strFYear,strLYear,iFYear,iLYear
strFYear=&quot;1/4/2001&quot; '(d/m/yyyy)
strFYear=&quot;31/3/2001&quot; '(d/m/yyyy)

iFYear=Year(strFYear)
iLYear=Year(strLYear)
%>

Now if I do something like this (note that I am not doing a Response.Write):

<% Year(strFYear) %>-<% Year(strLYear) %>

there is no problem & as expected, only the dash (-) can be seen in the browser. But now if I change the above to something like this (again no Response.Write):

<% iFYear %>-<% iLYear %>

an error is thrown saying Type mismatch 'iFYear'. Why so?

Thanks,

Arpan
 
Year(strFYear) is a function call which can exist on an asp line by itself (although it is not useful)

asp is confused when you just put a variable on the line by itself. Here is what your code is saying:
<%
Dim strFYear,strLYear,iFYear,iLYear
strFYear=&quot;1/4/2001&quot; '(d/m/yyyy)
strFYear=&quot;31/3/2001&quot; '(d/m/yyyy)

iFYear=Year(strFYear)
iLYear=Year(strLYear)
Year(strFYear)
%> - <%
Year(strLYear)
iFYear 'your error happens here first
%> - <%
iLYear
%>


-- Just trying to help...
[wolf]<--- This is a wolf? We need a new icon.......
mikewolf@tst-us.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top