Overwrites a substring of a string with another

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

The string to work with.
The start position in text of the substring to overwrite. The first character starts at position 1.
The number of characters to overwrite.

Copies a maximum of length characters of expression into text, starting at start.

If length is not specified, all of expression is copied. The size of the string text is unchanged; if expression is too big, as much of it is copied up to the end of text.

Mid can also be used as a function to return part of another string. See Mid (Function).

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"

Differences from QB:
See also:
Back to String Functions
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki

sf.net phatcode