10.6.3 Mid Assignment Statement
A Mid assignment statement assigns a string into another string. The left side of the assignment has the same syntax as a call to the function Microsoft.VisualBasic.Strings.Mid. The first argument is the target of the assignment and must be classified as a variable or a property access whose type is implicitly convertible to and from String. The second parameter is the 1-based start position that corresponds to where the assignment should begin in the target string and must be classified as a value whose type must be implicitly convertible to Integer. The optional third parameter is the number of characters from the right-side value to assign into the target string and must be classified as a value whose type is implicitly convertible to Integer. The right side is the source string and must be classified as a value whose type is implicitly convertible to String. The right side is truncated to the length parameter, if specified, and replaces the characters in the left-side string, starting at the start position.
The following example displays
Module Test Sub Main() Dim s1 As String = "abcdefg" Dim s2 As String = "1234567" Mid$(s1, 3, 3) = s2 Console.WriteLine(s1) End Sub End Module
Note Mid is not a reserved word.
MidAssignmentStatement ::= Mid [ $ ] ( Expression , Expression [ , Expression ] ) = Expression StatementTerminator
10.6.1 Regular Assignment Statements | 10.6.2 Compound Assignment Statements | 10.6 Assignment Statements | Mid Statement (Visual Basic Language Reference) | Assignment Statements (Visual Basic Language Concepts)