Solved

split string array with / in it.

Posted on 2013-02-03
5
320 Views
Last Modified: 2013-02-05
Hello All;

OK, I have a string like so.

Photoshop / After Effects
(or)
Access / Excel / Word
(or)
SQL Server

So it could have a / in the string, or there could not be, or there could be many of them.
It all really depends.
I need to replace the "Name" with an image
Like what you would do here.

if str = "Photoshop" then
WriteStr = "PS.jpg"
end if

I found this code, however, I cannot get it to show the images for each one, if there is more than one in the string.

This is within a LOOP, as shown in the code below.

<%
while not rs.eof
' There could be:
' Photoshop / After Effects
' (or)
' Access / Excel / Word
' (or)
' SQL Server
' In the following record, we need to SPLIT them form the / and then replace each item with an image.
' So if there is 3 items, then we need to have 3 images.
' and if there is 1 item, then we need only 1 image (This works)

myString = rs("MyField")

MyArray = split(VidCat,"/")
for counter = 0 to ubound(MyArray)
if MyArray(counter) = "Photoshop" then
response.Write  "<img src=""graph/Programs/PS.jp<wbr ></wbr>g"" height=""25"" />"
end if
if MyArray(counter) = "After Effects" then
response.Write  "<img src=""graph/Programs/AE.jp<wbr ></wbr>g"" height=""25"" />"
end if
if MyArray(counter) = "Sony Vegas" then
response.Write  "<img src=""graph/Programs/SonyV<wbr ></wbr>egas.jpg""<wbr ></wbr> height=""25"" />"
end if
if MyArray(counter) = "Adobe Edge Animate" then
response.Write  "<img src=""graph/Programs/An.jp<wbr ></wbr>g"" height=""25"" />"
end if
next
rs.movenext
wend
' This all works, except when there is multiple entries / within the string.
%>

Open in new window


Thanks All
Carrzkiss
0
Comment
Question by:Wayne Barron
[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
  • 3
  • 2
5 Comments
 
LVL 11

Accepted Solution

by:
madgino earned 500 total points
ID: 38850060
On line 15 you are spliting VidCat instead of mystring; then you have to use trim to eliminate spaces:

<%
while not rs.eof
' There could be:
' Photoshop / After Effects
' (or)
' Access / Excel / Word
' (or)
' SQL Server
' In the following record, we need to SPLIT them form the / and then replace each item with an image.
' So if there is 3 items, then we need to have 3 images.
' and if there is 1 item, then we need only 1 image (This works)

myString = rs("MyField")

MyArray = split(myString,"/")
for counter = 0 to ubound(MyArray)
if trim(MyArray(counter)) = "Photoshop" then
response.Write  "<img src=""graph/Programs/PS.jp<wbr ></wbr>g"" height=""25"" />"
end if
if trim(MyArray(counter)) = "After Effects" then
response.Write  "<img src=""graph/Programs/AE.jp<wbr ></wbr>g"" height=""25"" />"
end if
if trim(MyArray(counter)) = "Sony Vegas" then
response.Write  "<img src=""graph/Programs/SonyV<wbr ></wbr>egas.jpg""<wbr ></wbr> height=""25"" />"
end if
if trim(MyArray(counter)) = "Adobe Edge Animate" then
response.Write  "<img src=""graph/Programs/An.jp<wbr ></wbr>g"" height=""25"" />"
end if
next
rs.movenext
wend
' This all works, except when there is multiple entries / within the string.
%>

Open in new window

0
 
LVL 31

Author Comment

by:Wayne Barron
ID: 38850069
It works.....
0
 
LVL 31

Author Comment

by:Wayne Barron
ID: 38851695
I've requested that this question be closed as follows:

Accepted answer: 0 points for carrzkiss's comment #a38850069

for the following reason:

Thanks, spoke to soon on the last comment, then edited it real quick.<br /><br />Thanks a bunch, did not think about the TRIM, everything else was correct.<br />And the VidCat, that was taken from the original code.<br />I just added in the TRIM() and everything went to working.<br />You rock.<br />Have a great week.<br /><br />Carrzkiss
0
 
LVL 31

Author Closing Comment

by:Wayne Barron
ID: 38851696
(Lets try this again, I accepted it last night, but it did not take, EE must be having issues again)

Thanks, spoke to soon on the last comment, then edited it real quick.

Thanks a bunch, did not think about the TRIM, everything else was correct.
And the VidCat, that was taken from the original code.
I just added in the TRIM() and everything went to working.
You rock.
Have a great week.

Carrzkiss
0
 
LVL 11

Expert Comment

by:madgino
ID: 38854010
Thanks
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Title # Comments Views Activity
age from date of birth 4 63
Save ms data to server side. 19 64
SQL Query Returns Records in SSMS but not Classic ASP 5 46
calculate days away 11 61
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 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/…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

732 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