Thursday, August 12, 2010

Visual Basic String Function : Mid

Purpose : The Mid functions the specified portion of a string expression.

Syntax :
Mid ( strExpression , ingStart [ , ingLength ] )
MidB ( strExpression , ingStart [ , ingLength ] )

strExpression : Specifies the string from which you want to return a substring.
ingStart : Specifies the starting position for the returned substring.
ingLength : Specifies the number of characters of the returned substring.

Dim strGood as String
Dim strBye as String , strDolly as String
strGood = "Good bye, Dolly"
strBye = Mid ( strGood, 6 , 3 )
strDolly = Mid ( strGood , 11 )

The first example uses the Mid function to assign the value " bye " to the variable strBye. In the second example, the length parameter is omitted so the string returned starts where indicated and continues for the balance of then length of strGood . Therefore , the variable strDolly is assigned the value " Dolly "

No comments:

Post a Comment