• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 326
  • Last Modified:

split string array with / in it.

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
Wayne Barron
Asked:
Wayne Barron
  • 3
  • 2
1 Solution
 
madginoCommented:
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
 
Wayne BarronAuthor Commented:
It works.....
0
 
Wayne BarronAuthor Commented:
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
 
Wayne BarronAuthor Commented:
(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
 
madginoCommented:
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!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now