[Gambas-user] Indexing Strings?

T Lee Davidson t.lee.davidson at gmail.com
Thu Feb 13 18:47:10 CET 2020


http://gambaswiki.org/wiki/lang/type/string states, "The first character of a string is numbered one, not zero." Yet, this code:
   Dim sText As String = "Hello World"

   Print sText[1] 'prints "e"
   Print sText[0] 'prints "H"

appears to demonstrate that strings are indexed starting with 0. However, string functions seem to use a 1-based index.

What's the reason for this discrepancy?


-- 
Lee


More information about the User mailing list