Solved

convert int to String

Posted on 2006-11-14
6
6,393 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

746 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

7 Experts available now in Live!

Get 1:1 Help Now