Mid Statement


Mid Statement

Syntax

     Mid(target, start[, length]) = expression 


target (required; String)

The name of the string variable to be modified


start (required; Long)

The position within target at which the replacement begins


length (optional; Long)

The number of characters in target to replace


expression (required; String)

The string used to replace characters within target

Description

The Mid statement replaces a section of a string with characters from another string.

Usage at a Glance

  • If you omit length, as many characters of string as can fit into target are used.

  • If start + length is greater then the portion of target to be replaced, string is truncated to fit in the same space as that portion of target. The length of target is not altered by the Mid statement.

  • If start is less than zero, an error occurs.

  • If string is Nothing, a runtime error occurs.

  • VB includes the Replace function, which enhances the functionality of the Mid statement by allowing you to specify the number of times a replacement is carried out in the same string.

  • Because it is a statement, this version of Mid does not accept named arguments. Mid is implemented by the compiler rather than by the String data type.

See Also

Mid Function




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net