lang • type • string

String

DIM Var AS String

This datatype represents a variable-length string of characters.

The first character of a string is numbered one, not zero.

Theoretically, the string can contain null characters (i.e. character whose ASCII code is zero). But as some Gambas functions internally rely on zero-terminated strings, especially the methods of native class having string arguments, you should avoid them as much as possible!

Examples

Public sPub As String ' This string can be used by all subroutines in the same module

Public Sub Button1_Click()

  Dim sLoc As String ' This string is local in this subroutine

  sPub = "74zu88"
  sLoc = Mid$(sPub, 3, 2)
  If sLoc = "zu" Then Print "Expected"

End

See also