Share via


LSet 函式

更新:2007 年 11 月

傳回靠左對齊字串,這個字串包含調整成指定長度的指定字串。

Public Shared Function LSet( _
    ByVal Source As String, _
    ByVal Length As Integer _
) As String

參數

  • Source
    必要項。String 運算式。要調整的字串變數。

  • Length
    必要項。Integer 運算式。傳回的字串長度。

備註

如果 Source 的長度比 Length 長,則 LSet 只會傳回最左邊的字元,最長可達 Length 的長度。如果 Source 的長度比 Length 短,則 LSet 會在傳回字串的最右邊加上空格,以達到適合的長度。

範例

這個範例示範 LSet 函式的用法。

Dim TestString As String = "Left"
Dim lString As String
' Returns "Left      "
lString = LSet(TestString, 10)
' Returns "Le"
lString = LSet(TestString, 2)
' Returns "Left"
lString = LSet(TestString, 4)

需求

命名空間 (Namespace)︰Microsoft.VisualBasic

模組:Strings

組件:Visual Basic Runtime Library (在 Microsoft.VisualBasic.dll 中)

請參閱

概念

有效率地使用資料型別

參考

字串操作摘要

資料型別摘要 (Visual Basic)

RSet 函式