?
Solved

ASP Split syntax "type mismatch"

Posted on 2006-03-30
7
Medium Priority
?
326 Views
Last Modified: 2008-02-01
I have data in checkboes like the following

[]    123_ABC_01
[]    123_ABC_02
[]    123_ABC_03
[]    XYZX_ZZZ_01
[]    XYZX_ZZZ_02
[]    XYZX_ZZZ_04
[]    PTPR5_YYY_01
[]    PTPR5_YYY_02

I want to group them with a heading according to the string before the first  _(underscore)

Here is the code I used but I am getting a type mismatch
%>
<div align="center">
  <table border="1" width="18%" id="table1">
  <tr>
    <td width="97">
<%
             
            tmp = ""
               do while not objRS.EOF
                    if objRS("BldLabel") = strBuild then
                         strSelected = " Checked "
                    else
                         strSelected = ""
                    end if
                         
                         if Split(objRS("BldLabel"),"_", 1) <> tmp then
                              tmp = Split(objRS("BldLabel"),"_", 1)
                         %>
                         <tr><td><%=tmp%></td>
                         <%                                  
                         end if
 
%>
<tr><td><input type=checkbox name=BldLabel <%=strSelected%> value="<%=objRS("BldLabel")%>"></td>
<td><%=objRS("BldLabel")%></td>
</tr>
<%
                    objRS.MoveNext
               loop
          end if%>
          </table>
</div>
<%
0
Comment
Question by:tmurray22
  • 3
  • 2
  • 2
7 Comments
 
LVL 25

Expert Comment

by:kevp75
ID: 16334603
there are only 2 parameters to the split function
 like this:

split("stuff_to_split","splitting by")

this will put everything into an array for you, then just group it by the 1st value of the array (which is 0)

for example

myArray = SPLIT("123_ABC_DEF","_")
response.write myArray(0) & "<br />" 'this will print out 123 and a line break
response.write myArray(1) & "<br />" 'this will print out ABC and a line break
response.write myArray(2) & "<br />" 'this will print out DEF and a line break
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 16334936
>>there are only 2 parameters to the split function<<
Actually there are 4 parameters and only one is required.

<quote>
Split(expression[, delimiter[, count[, compare]]])

Arguments
expression
Required. String expression containing substrings and delimiters. If expression is a zero-length string, Split returns an empty array, that is, an array with no elements and no data.

delimiter
Optional. String character used to identify substring limits. If omitted, the space character (" ") is assumed to be the delimiter. If delimiter is a zero-length string, a single-element array containing the entire expression string is returned.

count
Optional. Number of substrings to be returned; -1 indicates that all substrings are returned.

compare
Optional. Numeric value indicating the kind of comparison to use when evaluating substrings. See Settings section for values.
</quote>
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 2000 total points
ID: 16335030
Just change:
    if Split(objRS("BldLabel"),"_", 1) <> tmp then

To:
    if Split(objRS("BldLabel"),"_")(0) <> tmp then         ' Split is 0 based.

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 25

Expert Comment

by:kevp75
ID: 16335187
ahh see.  I've never seen the last 2 being used, so I assumed there were only 2.

acperkins change should definatly work
0
 

Author Comment

by:tmurray22
ID: 16336049
I applied the chages but my data is strange (it gives a true above each check box and groups nothing)

Here is my original version which works fine, followed by my new version which doesnt.

 tmp = ""
               do while not objRS.EOF
                    if objRS("BldLabel") = strBuild then
                         strSelected = " Checked "
                    else
                         strSelected = ""
                    end if
                       if left("" & objRS("BldLabel"), 3) <> tmp then
                              tmp = left("" & objRS("BldLabel"), 3)
                         %>
                         <tr><td><%=tmp%></td>
                         <%                              
                         end if


Here is what I need to work

tmp = ""
               do while not objRS.EOF
                    if objRS("BldLabel") = strBuild then
                         strSelected = " Checked "
                    else
                         strSelected = ""
                    end if
                         
                         if Split(objRS("BldLabel"),"_")(0) <> tmp then
                              tmp = Split(objRS("BldLabel"),"_")(0) <> tmp
                         %>
                         <tr><td><%=tmp%></td>
                         <%                                  
                         end if

 
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 16339107
You are going to have to add a few Response.Write to see what is going on.

But at the very least I would say that you got carried away with your copy/paste.  This line:

tmp = Split(objRS("BldLabel"),"_")(0) <> tmp

Should work better this way:
tmp = Split(objRS("BldLabel"),"_")(0)
0
 

Author Comment

by:tmurray22
ID: 16339317
Holy Crap it worked. This morons going to bed!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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…
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…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month15 days, 3 hours left to enroll

840 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