| .NET DotNet Forum Index » VB.NET Forum (Visual Basic .NET) » strings... |
|
Page 1 of 1 |
|
| Author |
Message |
| mike... |
Posted: Fri Oct 30, 2009 3:20 pm |
|
|
|
Guest
|
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, ...) |
|
|
| Back to top |
|
|
|
| Armin Zingler... |
Posted: Fri Oct 30, 2009 3:29 pm |
|
|
|
Guest
|
mike schrieb:
Because of history.
Quote: '1st char position is 0 when using Asc but
num = Asc(password.Chars(x))
Asc doesn't use a position. The Chars property does.
Quote: '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 |
|
|
| Back to top |
|
|
|
| mike... |
Posted: Sat Oct 31, 2009 3:16 pm |
|
|
|
Guest
|
Armin,
i see. thx. that was bugging me!
"Armin Zingler" wrote:
Quote: mike schrieb:
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
.
|
|
|
| Back to top |
|
|
|
|