Navigation:  thinBasic Modules > Core > String handling >

RIGHT$

Previous pageReturn to chapter overviewNext page

 

Description

 

Return the rightmost n characters of a string.

 

Syntax

 

s = RIGHT$(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, LEFT$, 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