Lotus Symphony 1.2


Mid 函數、Mid 陳述式 [執行時期]

傳回字串表示式的指定部份 (Mid 函數),或用另一字串取代字串表示式的指定部份 (Mid 陳述式)。

語法:

Mid(Text As String, Start As Integer[, Length As Integer]) 或 Mid(Text As String, Start As Integer , Length As Integer, Text As String)

回覆值:

String (僅適用於函數)

參數:

Text:要修改的任意字串表示式。

Start:Integer 表示式,指出字串中想要取代或傳回的字串部份之字元位置。

Length:Integer 表示式,傳回要取代或傳回的字元數目。

如果不指定 Mid 函數中的 Length 參數,則會傳回字串表示式的所有字元 (從開始位置到字串結尾)。

如果 Mid 陳述式中的 Length 參數小於要取代文字的長度,則文字會縮短到指定的長度。

Text:取代字串表示式的字串 (Mid 陳述式)。

錯誤代碼

5 無效的程序呼叫

範例:

Sub ExampleUSDate

Dim sInput As String

Dim sUS_date As String

sInput = InputBox("Please input a date in the international format 'YYYY-MM-DD'")

sUS_date = Mid(sInput, 6, 2)

sUS_date = sUS_date & "/"

sUS_date = sUS_date & Right(sInput, 2)

sUS_date = sUS_date & "/"

sUS_date = sUS_date & Left(sInput, 4)

MsgBox sUS_date

End Sub


其他文件 | 商標