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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top