Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Mid() and Asc() functions in ASP pages... where have they gone...

149 views
Skip to first unread message

Craig Humphrey

unread,
Sep 1, 2000, 1:02:30 AM9/1/00
to
Hi,
either I'm doing something fundamentally wrong, or Mid() and Asc() are not
available in ASP pages.

I was building a function to work through a string and return the Ascii
equivalent (inline):

function convertString(strText)
Dim intI, strFake, chrThis, intThis, strThem
strFake = ""
chrThis = ""
For intI = 0 To len(strText) -1
chrThis = Mid(strText, intI, 1)
intThis = Asc(chrThis)
strThem = CStr(intThis)
strFake = strFake & chrThis & "[" & strThem & "]"
Next
convertString = strFake
end function

but I get the classic:
Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument: 'Mid'

error from the server.

The server is a vanilla NT4SP5 using IIS4. I have no idea what IIS service
packs have been applied, though I'm about to work through all the security
patches I can find...

Any clues people?

Later'ish
Craig

Marius Krogh

unread,
Sep 1, 2000, 3:06:26 AM9/1/00
to
Hi!
The loop in your code is wrong. You have to start to count from 1 and not 0.
The Mid function can not take 0 as the second parameter. The 'start'
(second) parameter starts with 1 and not 0.

Marius Krogh

"Craig Humphrey" <Craig.H...@ChapmanTripp.co.nz> wrote in message
news:ILGr5.2164$eZ8a.1...@news.xtra.co.nz...

Phillip Ward

unread,
Sep 1, 2000, 7:48:51 AM9/1/00
to
Craig,

VBScript indexes strings from 1, not zero, so

Mid( <String>, 0, 1 )

might upset it a little.
Change the loop to

For intI = 1 To Len(strText)

HTH,
Phill W.

Craig Humphrey wrote:

> Hi,
> either I'm doing something fundamentally wrong, or Mid() and Asc() are not
> available in ASP pages.

> . . .

Craig Humphrey

unread,
Sep 3, 2000, 6:11:00 PM9/3/00
to
Bingo!

Thanks... I'm too used to C/C++ and JavaScript...

Later'ish
Craig

"Marius Krogh" <ma...@online.no> wrote in message
news:8onki1$a94$1...@oslo-nntp.eunet.no...

Craig Humphrey

unread,
Sep 3, 2000, 6:11:19 PM9/3/00
to
Bingo!

Thanks... I'm too used to C/C++ and JavaScript...

Later'ish
Craig


"Phillip Ward" <Philli...@tesco.net> wrote in message
news:39AF97A3...@tesco.net...

0 new messages