[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

split string array with / in it.

Posted on 2013-02-03
5
Medium Priority
?
325 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 2000 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

Independent Software Vendors: 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 recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

656 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