MID(语句)
- 来源: https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgMidstatement
- 最后更新: 2016-03-13
用另一个字符串覆盖字符串的子字符串
语法
vb
declare sub Mid ( byref text as string, byval start as integer, byval length as integer, byref expression as const string )
declare sub Mid ( byval text as wstring ptr, byval start as integer, byval length as integer, byval expression as const wstring ptr )用法
Mid( text, start ) = expression
或
Mid( text, start, length ) = expression参数
text
要操作的字符串。
start
text 中要覆盖的子字符串起始位置。第一个字符的位置为 1。
length
要覆盖的字符数。
说明
将 expression 中最多 length 个字符复制到 text 中,从 start 位置开始。
若未指定 length,则复制 expression 的全部内容。字符串 text 的大小不变;若 expression 过长,则复制尽可能多的内容直到 text 末尾。
Mid 也可作为函数使用,返回另一个字符串的一部分。参见 Mid(函数)。
示例
vb
Dim text As String
text = "abc 123"
Print text 'displays "abc 123"
' replace part of text with another string
Mid(text, 5, 3) = "456"
Print text 'displays "abc 456"与 QB 的差异
- 无
另请参阅
返回 目录