Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mistake in the Asc() VB function?

Tags:

string

vb.net

Could you please tell why the Asc() function returns incorrect result?

    Dim TestChar = Chr(128)
    Dim CharInt = Asc(TestChar) ' this is a mistake on Windows 7 x64. Asc(TestChar) returns 136 instead of 128

I executed this code on another computer and the result was 128.

Thanks.

like image 567
Alexander Avatar asked Dec 08 '22 03:12

Alexander


1 Answers

Your computer is using a different default code page.

The Asc function uses the system's current ANSI code page.
The Chr function simply casts the value to char. (Unless it's > 255)

like image 57
SLaks Avatar answered Dec 11 '22 10:12

SLaks