Skip to content

Mid Statement

Paul Squires edited this page Oct 19, 2026 · 2 revisions

Home › String Functions › Mid (Statement)

Mid (Statement)

Overwrites part of a string in place with other text.

Syntax

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 )

Parameters

  • text
  • start
  • text
  • length

Description

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).

Remarks

Usage

Mid( text, start ) = expression

Or

Mid( text, start, length ) = expression

Differences from QB

  • None

See also

Examples

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"

Category: String Functions
Kind: statement


Reproduced from the FreeBASIC Wiki Manual under the GNU Free Documentation License 1.3 — with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. Copyright © the FreeBASIC project and wiki contributors. See License.

Clone this wiki locally