字符串1/2,怎么拆分出1和2?
字符串1/2,怎么拆分出1和2? GetField FunctionReturns a substring from a source string.
SYNTAX
GetField[$]( string$ , field_number% , separator_chars$ )
Syntax
Element Description
$ Optional. If specified, the return type is String. If omitted, the function typically returns a Variant of VarType 8 (String).
string$ A list of fields, divided by separator characters.
field_number% The number of the field to return, starting with 1.
separator_chars$ The characters separating each field.
COMMENTS
If field_number is greater than the number of fields in the string, an empty string ("") is returned.
Multiple separator characters can be specified, but they can’t be used together. For example, the code in the first bullet below is correct, but the code in the second bullet retrieves an incorrect field:
· retvalue = GetField("9-8;7;6-5",3,"-;")
· retvalue = GetField("9-;8-;7-;6-;5",3,"-;") This example finds the third value in a string, delimited by plus signs (+).
Sub main
Dim teststring,retvalue
Dim msgtext
teststring="9+8+7+6+5"
retvalue=GetField(teststring,3,"+")
MsgBox "The third field in: " & teststring & " is: " & retvalue
End Sub getfield(string,位置,"分隔符")
页:
[1]