PDA

View Full Version : دستور Split



leila.66
دوشنبه 14 شهریور 1390, 18:38 عصر
سلام :
ممکنه یکی این دستورو دقیقا توضیح بده ممنون:



"), ", (A = Split(s , Array(1

b_savad
سه شنبه 15 شهریور 1390, 09:38 صبح
Function Split(
ByVal Expression As String,
Optional ByVal Delimiter As String = " ",
Optional ByVal Limit As Integer = -1,
Optional ByVal Compare As CompareMethod = CompareMethod.Binary
) As String()


Parameters
Expression
Required. String expression containing substrings and delimiters.

Delimiter
Optional. Any single character used to identify substring limits. If Delimiter is omitted, the space character (" ") is assumed to be the delimiter.

Limit
Optional. Maximum number of substrings into which the input string should be split. The default, –1, indicates that the input string should be split at every occurrence of the Delimiter string.

Compare
Optional. Numeric value indicating the comparison to use when evaluating substrings. See "Settings" for values.

Returns
String array. If Expression is a zero-length string (""), Split returns a single-element array containing a zero-length string. If Delimiter is a zero-length string, or if it does not appear anywhere in Expression, Split returns a single-element array containing the entire Expression string.


این بالا شکل کلی تابع split رو می گه
اما دستور شما
دستور شما میگه رشته s رو با کاراکتر خانه 1 آرایه array تقسیم کن و نتایج رو توی آرایه ی رشتهای a بذار

یک مثال:
Split Call
Return Value

Split("42, 12, 19")
{"42," , "12," , "19"}

Split("42, 12, 19", ", ")
{"42", "12", "19"}

Split("42, 12, 19", ", ", 2)
{"42", "12, 19"}

Split("192.168.0.1", ".")
{"192", "168", "0", "1"}

Split("Alice and Bob", " AND ")
{"Alice and Bob"}

Split("Alice and Bob", " AND ", ,CompareMethod.Text)
{"Alice", "Bob"}

Split("someone@example.com", "@",1)
{"someone@example.com"}

Split("someone@example.com", "@",2)
{"someone", "example.com"}