ASP Split syntax "type mismatch"

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>
<%
tmurray22Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kevp75Commented:
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
Anthony PerkinsCommented:
>>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>
Anthony PerkinsCommented:
Just change:
    if Split(objRS("BldLabel"),"_", 1) <> tmp then

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

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

acperkins change should definatly work
tmurray22Author Commented:
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

 
Anthony PerkinsCommented:
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)
tmurray22Author Commented:
Holy Crap it worked. This morons going to bed!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.