strings

  • Thread starter Thread starter mike
  • Start date Start date
M

mike

why is that :

'1st char position is 0 when using Asc but
num = Asc(password.Chars(x))

'1st char position is 1 when using InStr
num = InStr(password, ...)
 
mike said:
why is that :

Because of history.
'1st char position is 0 when using Asc but
num = Asc(password.Chars(x))

Asc doesn't use a position. The Chars property does.
'1st char position is 1 when using InStr
num = InStr(password, ...)


InStr existed before VB.Net. In VB6 (and below), the index was one-based.
This hasn't been changed in VB.Net to avoid confusion and breaking compatibility.

The Chars property is part of the the .Net Framework that is not specific to
VB. The Framework consistenly uses zero-based indexes.
 
Armin,

i see. thx. that was bugging me!

Armin Zingler said:
Because of history.


Asc doesn't use a position. The Chars property does.



InStr existed before VB.Net. In VB6 (and below), the index was one-based.
This hasn't been changed in VB.Net to avoid confusion and breaking compatibility.

The Chars property is part of the the .Net Framework that is not specific to
VB. The Framework consistenly uses zero-based indexes.
 
Back
Top