Connecting Tech Pros Worldwide Forums | Help | Site Map

Split() function gives type mismatch

Alan Silver
Guest
 
Posts: n/a
#1: Jul 19 '05
Hello,

I have been having problems with some blindingly simple ASP that fails.
I have the following code ...

Dim sAds, sAdverts()
sAds = "1" & vbTab & "Ferret" & vbTab & "Furry" & vbCrLf
sAds = sAds & "2" & vbTab & "Gibbon" & vbTab & "HAiry" & vbCrLf
sAds = sAds & "3" & vbTab & "Vole" & vbTab & "Small" & vbCrLf
sAdverts = Split(sAds,vbCrLf)

Which gives a Type Mismatch error on the Split() line. I have done this
sort of thing loads of times before and can't understand why this isn't
working. The code above is a test version, designed to pinpoint the
problem lines. The real code is supposed to get data from a database and
convert the ADODB recordset to an array using GetRows(). When that
failed, I cut the code down to the above.

This is running on IIS6 on Windows 2003 Server. This is the first time I
have done any ASP on this machine (only just installed it). ASP seems to
be working fine as other stuff previously written goes without problems.

Any idea why Split() doesn't work?

TIA for any help.

--
Alan Silver
(anything added below this line is nothing to do with me)


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----

Aaron [SQL Server MVP]
Guest
 
Posts: n/a
#2: Jul 19 '05

re: Split() function gives type mismatch


You can't pre-assign sAdverts as an array. So, change:
[color=blue]
> Dim sAds, sAdverts()[/color]

to:

Dim sAds, sAdverts

--
http://www.aspfaq.com/
(Reverse address to reply.)


Ray Costanzo [MVP]
Guest
 
Posts: n/a
#3: Jul 19 '05

re: Split() function gives type mismatch


Although this seems illogical, don't DIM your sAdverts variable as a dynamic
array. Do:

Dim sAds, sAdverts

instead of

Dim sAds, sAdverts()

Then all will be fine.

Ray at work

"Alan Silver" <alan-silver@nospam.thanx> wrote in message
news:JQm5xWCCBdWBFw$D@nospamthankyou.spam...[color=blue]
> Hello,
>
> I have been having problems with some blindingly simple ASP that fails. I
> have the following code ...
>
> Dim sAds, sAdverts()
> sAds = "1" & vbTab & "Ferret" & vbTab & "Furry" & vbCrLf
> sAds = sAds & "2" & vbTab & "Gibbon" & vbTab & "HAiry" & vbCrLf
> sAds = sAds & "3" & vbTab & "Vole" & vbTab & "Small" & vbCrLf
> sAdverts = Split(sAds,vbCrLf)
>
> Which gives a Type Mismatch error on the Split() line. I have done this
> sort of thing loads of times before and can't understand why this isn't
> working. The code above is a test version, designed to pinpoint the
> problem lines. The real code is supposed to get data from a database and
> convert the ADODB recordset to an array using GetRows(). When that failed,
> I cut the code down to the above.
>
> This is running on IIS6 on Windows 2003 Server. This is the first time I
> have done any ASP on this machine (only just installed it). ASP seems to
> be working fine as other stuff previously written goes without problems.
>
> Any idea why Split() doesn't work?
>
> TIA for any help.
>
> --
> Alan Silver
> (anything added below this line is nothing to do with me)
>
>
> -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
> http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
> -----== Over 100,000 Newsgroups - 19 Different Servers! =-----[/color]


Alan Silver
Guest
 
Posts: n/a
#4: Jul 19 '05

re: Split() function gives type mismatch


"Aaron [SQL Server MVP]" <ten.xoc@dnartreb.noraa> wrote in message news:<uqAWZAapEHA.3572@TK2MSFTNGP10.phx.gbl>...[color=blue]
> You can't pre-assign sAdverts as an array. So, change:
>[color=green]
> > Dim sAds, sAdverts()[/color]
>
> to:
>
> Dim sAds, sAdverts[/color]

Thanx to both of you. Is this something that's changed between the
version of VBScript in IIS4 and the version in IIS6 ? I haven't done
much ASP for a while, and this is the first time I've used IIS6, but
I'm sure I used to have the brackets there before (yup, could be wrong
here !!).

Thanx again
Bob Barrows [MVP]
Guest
 
Posts: n/a
#5: Jul 19 '05

re: Split() function gives type mismatch


Alan Silver wrote:[color=blue]
> "Aaron [SQL Server MVP]" <ten.xoc@dnartreb.noraa> wrote in message
> news:<uqAWZAapEHA.3572@TK2MSFTNGP10.phx.gbl>...[color=green]
>> You can't pre-assign sAdverts as an array. So, change:
>>[color=darkred]
>>> Dim sAds, sAdverts()[/color]
>>
>> to:
>>
>> Dim sAds, sAdverts[/color]
>
> Thanx to both of you. Is this something that's changed between the
> version of VBScript in IIS4 and the version in IIS6 ? I haven't done
> much ASP for a while, and this is the first time I've used IIS6, but
> I'm sure I used to have the brackets there before (yup, could be wrong
> here !!).[/color]

Nope, it's always worked this way. You only use the parentheses when you are
dimensioning and populating the array yourself.

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


Alan Silver
Guest
 
Posts: n/a
#6: Jul 19 '05

re: Split() function gives type mismatch


<snip>[color=blue][color=green]
>> Thanx to both of you. Is this something that's changed between the
>> version of VBScript in IIS4 and the version in IIS6 ? I haven't done
>> much ASP for a while, and this is the first time I've used IIS6, but
>> I'm sure I used to have the brackets there before (yup, could be wrong
>> here !!).[/color]
>
>Nope, it's always worked this way. You only use the parentheses when you are
>dimensioning and populating the array yourself.[/color]

OK, I told you it's been a while since I did any ASP ;-)

Thanx for the reply.

Whilst I've got your attention, do you know of any resources that will
update my ASP knowledge. I was a very competent ASP programmer a couple
of years back (I know, my question above doesn't make you think so !!)
and I don't really want an ASP 101 resource, I just want something that
will tell me what's new since IIS4. I have looked around, but not found
anything worthwhile yet. Any suggestions ?

Thanx

--
Alan Silver
(anything added below this line is nothing to do with me)


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Bob Barrows [MVP]
Guest
 
Posts: n/a
#7: Jul 19 '05

re: Split() function gives type mismatch


Alan Silver wrote:[color=blue]
> <snip>[color=green][color=darkred]
>>> Thanx to both of you. Is this something that's changed between the
>>> version of VBScript in IIS4 and the version in IIS6 ? I haven't done
>>> much ASP for a while, and this is the first time I've used IIS6, but
>>> I'm sure I used to have the brackets there before (yup, could be
>>> wrong here !!).[/color]
>>
>> Nope, it's always worked this way. You only use the parentheses when
>> you are dimensioning and populating the array yourself.[/color]
>
> OK, I told you it's been a while since I did any ASP ;-)
>
> Thanx for the reply.
>
> Whilst I've got your attention, do you know of any resources that will
> update my ASP knowledge. I was a very competent ASP programmer a
> couple of years back (I know, my question above doesn't make you think so
> !!)
> and I don't really want an ASP 101 resource, I just want something
> that will tell me what's new since IIS4. I have looked around, but
> not found anything worthwhile yet. Any suggestions ?
>
> Thanx[/color]
http://msdn.microsoft.com/library
www.aspfaq.com
www.iisfaq.com

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


Alan Silver
Guest
 
Posts: n/a
#8: Jul 19 '05

re: Split() function gives type mismatch


<snip>[color=blue][color=green]
>> Whilst I've got your attention, do you know of any resources that will
>> update my ASP knowledge. I was a very competent ASP programmer a
>> couple of years back (I know, my question above doesn't make you think so
>> !!)
>> and I don't really want an ASP 101 resource, I just want something
>> that will tell me what's new since IIS4. I have looked around, but
>> not found anything worthwhile yet. Any suggestions ?
>>
>> Thanx[/color]
>http://msdn.microsoft.com/library[/color]

Having looked in vain here before, I just spent the last couple of hours
reading loads of articles that answered my questions completely !! Don't
know how I missed them at all.
[color=blue]
>www.aspfaq.com[/color]

Couldn't find anything that addressed this issue. Good site generally,
but failed me this time.
[color=blue]
>www.iisfaq.com[/color]

Didn't know about this one. Thanx for the link, I'll check it out.

--
Alan Silver
(anything added below this line is nothing to do with me)


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Closed Thread