?
Solved

split string array with / in it.

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

Industry Leaders: 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 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 informatio…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

770 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