wsryyffs 发表于 2006-9-29 12:54:18

字符串1/2,怎么拆分出1和2?

字符串1/2,怎么拆分出1和2?

5am 发表于 2006-9-29 17:02:20

GetField Function


Returns 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,"-;")

5am 发表于 2006-9-29 17:03:46

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

colume 发表于 2006-10-8 20:38:46

getfield(string,位置,"分隔符")
页: [1]
查看完整版本: 字符串1/2,怎么拆分出1和2?