傳回字串,其中包含從字串的右邊開始的指定數目的字元。
命名空間: Microsoft.VisualBasic
組件: Microsoft.VisualBasic (在 microsoft.visualbasic.dll 中)
語法
'宣告
Public Shared Function Right ( _
str As String, _
Length As Integer _
) As String
'用途
Dim str As String
Dim Length As Integer
Dim returnValue As String
returnValue = Strings.Right(str, Length)
public static string Right (
string str,
int Length
)
public:
static String^ Right (
String^ str,
int Length
)
public static String Right (
String str,
int Length
)
public static function Right (
str : String,
Length : int
) : String
參數
- str
必要項。String 運算式,最右邊的字元會從此運算式中傳回。
- Length
必要項。Integer - 數值運算式,表示要傳回的字元數。如果為 0,則會傳回長度為零的字串 ("")。如果大於或等於 str 中的字元數,則會傳回整個字串。
傳回值
傳回字串,其中包含從字串的右邊開始的指定數目的字元。
備註
如需詳細資訊,請參閱 Visual Basic 的主題 Right 函式 (Visual Basic)。
若要判斷 str 中的字元數,請使用 Len 函式。如果用於 Windows Form 或具有 Right 屬性的任何其他類別中,您必須以Microsoft.VisualBasic.Right 來完整限定此函式。
注意事項 |
|---|
舊版 Visual Basic 中的 RightB 函式會傳回位元組中的字串,而非字元。這項功能主要用來轉換雙位元組字元集 (DBCS) 應用程式中的字串。目前所有的 Visual Basic 字串都以 Unicode 編碼,且不再支援 RightB。 |
範例
此範例將示範如何使用 Right 函式,以傳回給定之 String 的子字串。在具有 Right 屬性的類別中,它可能必須要完整限定 Right 函式。
Dim TestString As String = "Hello World!"
' Returns "World!".
Dim subString As String = Microsoft.VisualBasic.Right(TestString, 6)
平台
Windows 98、 Windows 2000 SP4、 Windows CE、 Windows Millennium Edition、 Windows Mobile for Pocket PC、 Windows Mobile for Smartphone、 Windows Server 2003、 Windows XP Media Center Edition、 Windows XP Professional x64 Edition、 Windows XP SP2、 Windows XP Starter Edition
.NET Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱系統需求一節的內容。
版本資訊
.NET Framework
支援版本:2.0、1.1、1.0
.NET Compact Framework
支援版本:2.0、1.0
請參閱
參考
Strings 類別
Strings 成員
Microsoft.VisualBasic 命名空間
ArgumentException
其他資源
Right 函式 (Visual Basic)
字串操作摘要
Left 函式 (Visual Basic)
Len 函式 (Visual Basic)
Mid 函式 (Visual Basic)
程式設計項目的支援變更摘要
注意事項