VB split string Array string
VB split string arrays, VB string to array:
Dim B () as String
B () = Split ("1,2,3,4,dsd-ad5,6,45,656465,564,45″,", ") ' Split into array
MsgBox B (4) ' Read fifth, starting from 0
Split function: Returns a zero-based, one-dimensional array that contains the specified number of substrings.
Parameters
Expression must be selected. A string expression that contains substrings and delimiters. If Expression is a 0-length string (""), the Split function returns an array of length one containing an empty string.
Delimiter options available. A single character that identifies the bounds of the substring. If Delimiter is omitted, the white space character ("") is assumed to be a delimiter. If Delimiter is a zero-length string, returns a group of cell primes that contain the entire Expression string.
The Limit option is available. The number of substrings to return; The default value is-1, which means that all substrings are returned.
Compare options available. Numeric value indicating the comparison mode to use when calculating substrings. See settings for specific values.
The set Compare parameter can have the following values:
Constant description
Binary comparison binary execution
Text execution comparison
Mid Function Example
This example uses the Mid statement to get a few characters from a string.
Dim MyString, FirstWord, Lastword, midwords
MyString = "Mid Function Demo" establishes a string.
FirstWord = Mid (MyString, 1, 3) ' Return to mid '.
Lastword = Mid (MyString, 14, 4) ' returns ' Demo '.
Midwords = Mid (MyString, 5) ' Return to ' funcion Demo '.
Left Function Example
This example uses the left function to get the leftmost number of characters in a string.
Dim AnyString, MyStr
anystring = "Hello World" defines the string.
MyStr = Left (anystring, 1) ' returns ' H '.
MyStr = Left (anystring, 7) ' returns ' Hello W '.
MyStr = Left (anystring, 20) ' Return to ' Hello world '.
Example of the right function
This example uses the right function to return a few characters from the left side of a string.
Dim AnyString, MyStr
anystring = "Hello World" defines the string.
MyStr = Right (anystring, 1) ' returns ' d '.
MyStr = Right (anystring, 6) ' Return to ' world '.
MyStr = Right (anystring, 20) ' Return to ' Hello world '.
_______ Description ___________________________________
Left function
Returns a Variant (string) that contains the specified number of characters from the left side of the string.
Grammar
Left (string, length)
The syntax for the left function has the following named arguments:
Section description
String necessary parameters. The string expression where the leftmost characters are returned. If string contains null, NULL is returned.
The length is the necessary parameter; a Variant (Long). A numeric expression that indicates how many characters will be returned. If 0, returns a 0-length string (""). If the number of characters is greater than or equal to string, the entire string is returned.
Description
To know the number of characters in a string, use the Len function.
Note the LeftB function acts on the byte data contained in the string. So length specifies the number of bytes, not the number of characters to return.
Right function
Returns a Variant (string) that contains the specified number of characters taken from the right side of the string.
Grammar
Right (string, length)
The syntax of the right function has the following named arguments:
Section description
String necessary parameters. A string expression in which the rightmost character is returned. If string contains null, NULL is returned.
The length is the necessary parameter; a Variant (Long). As a numeric expression that indicates how many characters you want to return. If 0, returns a 0-length string (""). If the number of characters is greater than or equal to string, the entire string is returned.
Description
To know the number of characters in a string, use the Len function.
Note the RightB function acts on the byte data contained in the string. So length specifies the number of bytes, not the number of characters returned.
Mid function
Returns a Variant (string) that contains the specified number of characters in the string.
Grammar
Mid (String, start[, length])
The grammar of the MID function has the following named arguments:
Section description
String necessary parameters. A string expression from which to return the character. If string contains null, NULL is returned.
Start the necessary parameters. To Long. The character position of the extracted part of the string. If start exceeds the number of characters in string, Mid returns a 0-length string ("").
The length is optional and is Variant (Long). The number of characters to return. If omitted or length exceeds the number of characters in the text (including the character at start), all characters from start to end of the string are returned.
Description
To know the number of characters in a string, use the Len function.
Note the MidB function acts on the byte data contained in the string, as in a double-byte character set (DBCS) language. Therefore, its parameters specify the number of bytes, not the number of characters. For sample code that uses MIDB, see the second example in the example topic.