Solved

convert int to String

Posted on 2006-11-14
6
6,406 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
[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
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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/…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

752 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