Solved

convert int to String

Posted on 2006-11-14
6
6,400 Views
Last Modified: 2009-12-16
I have the following code and I think it's not working because I need to convert an int to a string but not sure how.  The problem is generating the URL's where I have put <%=CStr(curDay)%>.

<%
blankDays = 7 - firstDay
curDay = 1
while(blankDays >= 0)
%>
    <td height="100"> <p><a href="/Calendars/CalendarDetail.asp?EventDate=11/"<%=CStr(curDay)%>"/2006&ScheduleID=<%=scheduleID%>"><img src="/Images/Calendar/"<%=CStr(curDay)%>".jpg" width="100" height="15" border="0" align="top"></a></p>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
      </table></td>
<%
blankDays = blankDays -1
curDay = curDay +1
wend
%>



Thanks
0
Comment
Question by:mgcIT
6 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17940617
>I have the following code and I think it's not working because I need to convert an int to a string but not sure how.
why? and formatting requirements?

<%
blankDays = 7 - firstDay
curDay = 1
while(blankDays >= 0)


c = cstr(curDay)
if (len(c)= 1) then c = "0" & c

%>
    <td height="100"> <p><a href="/Calendars/CalendarDetail.asp?EventDate=11/"<%=c%>"/2006&ScheduleID=<%=scheduleID%>"><img src="/Images/Calendar/"<%=c%>".jpg" width="100" height="15" border="0" align="top"></a></p>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
      </table></td>
<%
blankDays = blankDays -1
curDay = curDay +1
wend
%>
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 17940621
mgcIT,

That is the correct way to convert it.  What is the error you are getting?  Try using the line below to see what type that variable is.

Response.Write vartype(curDay)

Let me know if you have any questions or need more information.

b0lsc0tt
0
 
LVL 18

Author Comment

by:mgcIT
ID: 17940750
>>why? and formatting requirements?

This basically should create a series of links (in a table) that would look like:

/Calendars/CalendarDetail.asp?EventDate=11/1/2006&ScheduleID=4
/Calendars/CalendarDetail.asp?EventDate=11/2/2006&ScheduleID=4
/Calendars/CalendarDetail.asp?EventDate=11/3/2006&ScheduleID=4
/Calendars/CalendarDetail.asp?EventDate=11/4/2006&ScheduleID=4

and the links themselves are actually images named like so:

/Images/Calendar/1.jpg
/Images/Calendar/2.jpg
/Images/Calendar/3.jpg
/Images/Calendar/4.jpg
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

 
LVL 18

Author Comment

by:mgcIT
ID: 17941128
>>Response.Write vartype(curDay)

the output from this statement = 2

the error I am having is that it doesn't properly write the links.  It comes out as:

/Calendars/CalendarDetail.asp?EventDate=11/

and the image src comes out as:

/Images/Calendar/
0
 
LVL 58

Accepted Solution

by:
amit_g earned 500 total points
ID: 17941327
Looks like you have incorrect quotes placement. Change

    <td height="100"> <p><a href="/Calendars/CalendarDetail.asp?EventDate=11/"<%=CStr(curDay)%>"/2006&ScheduleID=<%=scheduleID%>"><img src="/Images/Calendar/"<%=CStr(curDay)%>".jpg" width="100" height="15" border="0" align="top"></a></p>

to

    <td height="100"> <p><a href="/Calendars/CalendarDetail.asp?EventDate=11/<%=CStr(curDay)%>/2006&ScheduleID=<%=scheduleID%>"><img src="/Images/Calendar/<%=CStr(curDay)%>.jpg" width="100" height="15" border="0" align="top"></a></p>
0
 
LVL 18

Author Comment

by:mgcIT
ID: 17941499
yep that was it....

Thanks for the help!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

828 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