Bookshelf Home | Contents | Index | Search | PDF |
Siebel VB Language Reference > Siebel VB Language Reference >
Mid Function
This standard VB function returns a portion of a string, starting at a specified location within the string.
Syntax
Mid[$](string, start[, length])
Returns
A substring of string, of length length, beginning at the start character of string.
Usage
Mid accepts any type of string, including numeric values, and converts the input value to a string. If the length argument is omitted or if string is smaller than length, then Mid returns computer characters in string. If start is larger than string, then Mid returns an empty string ("").
The index of the first character in a string is 1.
The dollar sign ($) in the function name is optional. If it is included, the return type is string. Otherwise the function typically returns a variant of vartype 8 (string). If the value of string is Null, a variant of vartype 1 (Null) is returned. Mid$ requires the string argument to be of type string or variant. Mid allows the string argument to be of any data type.
To modify a portion of a string value, read Mid Statement.
Example
This example uses the Mid function to find the last name in a string entered by the user.
Sub Button_Click
Dim username as String
Dim position as Integer
username = "Chris Smith"
Do
position = InStr(username," ")
If position = 0 then
Exit Do
End If
position = position + 1
username = Mid(username,position)
Loop
End SubSee Also
Left Function
Len Function
LTrim Function
Mid Function
Right Function
RTrim Function
Trim Function
Bookshelf Home | Contents | Index | Search | PDF |
Siebel VB Language Reference Published: 18 June 2003 |