共用方式為


Strings.Space 方法

傳回字串,此字串是由指定之空格數所組成。

命名空間: Microsoft.VisualBasic
組件: Microsoft.VisualBasic (在 microsoft.visualbasic.dll 中)

語法

'宣告
Public Shared Function Space ( _
    Number As Integer _
) As String
'用途
Dim Number As Integer
Dim returnValue As String

returnValue = Strings.Space(Number)
public static string Space (
    int Number
)
public:
static String^ Space (
    int Number
)
public static String Space (
    int Number
)
public static function Space (
    Number : int
) : String

參數

  • Number
    必要項。Integer 運算式。您希望在字串中有多少空格數。

傳回值

傳回字串,此字串是由指定之空格數所組成。

備註

如需詳細資訊,請參閱 Visual Basic 的主題 Space 函式 (Visual Basic)

Space 函式對於格式化輸出以及清除固定長度字串的資料非常實用。

範例

此範例使用 Space 函式,傳回由指定之空格數組成的字串。

Dim TestString As String
' Returns a string with 10 spaces.
TestString = Space(10)
' Inserts 10 spaces between two strings.
TestString = "Hello" & Space(10) & "World"

平台

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

其他資源

Space 函式 (Visual Basic)
字串操作摘要
SPC 函式