In JScript, the function charCodeAt(n) returns an integer
representing the Unicode encoding of the character at the
n+1 position as shown in the following example.
How can we do the same using VBScript or Visual Basic?

Thanks,
Bob

///////////EXAMPLE///////////////////////
<html>
<head>
<script language="jscript">

function charCodeAtTest(n){

var str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var n;
n = str.charCodeAt(n); //Get the Unicode
value of the
// character at
position n+1.
alert(n);
}

</script>

</head>

<body onload="charCodeAtTest(2)">

Test for charCodeAt(2). The function will return 67 --
the integer representing Unicode encoding of the
character "C"

</body>

</html>

////////////////////////

Re: Returning Unicode value of the character by Auric__

Auric__
Mon Jun 21 00:29:05 CDT 2004

On Sun, 20 Jun 2004 21:00:40 -0700, Bob wrote:

>In JScript, the function charCodeAt(n) returns an integer
>representing the Unicode encoding of the character at the
>n+1 position as shown in the following example.
>How can we do the same using VBScript or Visual Basic?

You want either Asc (returns the ASCII value of the first character in
the string passed) or AscW (same as Asc but returns the Unicode value -
same for 0..255).

>Thanks,
>Bob
>
>///////////EXAMPLE///////////////////////
><html>
><head>
><script language="jscript">
>
>function charCodeAtTest(n){
>
> var str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
> var n;
> n = str.charCodeAt(n); //Get the Unicode
>value of the
> // character at
>position n+1.
> alert(n);
>}

There's a bug in your code, Bob. You use n as both an argument for the
function *and* a variable inside the function. Messy, messy. Change one
of them to something else.

></script>
>
></head>
>
><body onload="charCodeAtTest(2)">
>
> Test for charCodeAt(2). The function will return 67 --
>the integer representing Unicode encoding of the
>character "C"
>
></body>
>
></html>

Sub charCodeAtTest(n)
' 0 < n <= Len(St)
' also, Str is a keyword in VB dialects - chopped to St
St = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
x = AscW(Mid(St, n))
MsgBox x
End Sub

[...]

<body onload="vbscript:charCodeAtTest(2)">

This would work just fine in Visual Basic, too (except for <body...> ),
though I'd redo it a bit to take advantage of data types.
--
auric underscore underscore at hotmail dot com
*****
- So, anyway, what do you want to go do later?
- Oh, you know. The usual. Dig a hole in the ground. Crawl into it. Stay
there. Fucking HIDE.