Solved

convert int to String

Posted on 2006-11-14
6
6,414 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

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…
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

632 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