Solved

convert int to String

Posted on 2006-11-14
6
6,395 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 142

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
add custom headers to my mail 2 47
Adding Datediff to staistics page 2 49
Auto Submit on dropdown box 3 54
Questions about INCLUDE FILES 2 17
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…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

932 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now