Navigation:  thinBasic Modules > Core > String handling >

LEFT$

Previous pageReturn to chapter overviewNext page

 

Description

 

Return the left-most n characters of a string.

 

Syntax

 

s = LEFT$(StringExpression, nChars)

 

Returns

 

String

 

Parameters

 

Name

Type

Optional

Meaning

StringExpression

String

No

Original string from which portion will be extracted

nChars

Numeric

No

Number of chars to return

 

Remarks

 

Restrictions

 

See also

 

String Handling, RIGHT$, MID$,

 

Examples

 

Thanks to Abraxas for the following script example

' Usage of the LEFT$ Keyword example

' Usage of the MID$ Keyword example

' Usage of the RIGHT$ Keyword example

 

Dim MyOLDString   As String VALUE "HELLO WORLD"

Dim MyLEFTString  As String

Dim MyMIDString   As String

Dim MyRIGHTString As String

Dim sMsg          As String

 

MyLEFTString  = LEFT$ (MyOLDString, 4) 

MyMIDString   = MID$  (MyOLDString, 4, 2) 

MyRIGHTString = RIGHT$(MyOLDString, 5)

 

sMsg += "Normal " & MyOLDString   & $CRLF & $CRLF

sMsg += "LEFT$ "  & MyLEFTString  & $CRLF & $CRLF

sMsg += "MID$ "   & MyMIDString   & $CRLF & $CRLF

sMsg += "RIGHT$ " & MyRIGHTString & $CRLF & $CRLF

 

MSGBOX 0, sMsg

 

 

 

 

© 2004-2008 thinBasic. All rights reserved. Version 1.7.0.0 Web Site: http://www.thinbasic.com