Segment the string and obtain each content

zhaozj2021-02-16  99

When programming in VB or VB.NET, we may put some values ​​inside such format. "123-456-123-456-123-456-123", not put it in an array. The situation is actually more common. The company where the author is located, the web page or Window app, often from a page to send a lot of values ​​to another page, and the value does not know, often use this Method is realized.

When you get such a string, you have to decline. Get the value of each segment, which requires the string to segment the string, get the problem of each segment. The following is a function that the author is used in the development. .vb6 or successful compilation on VB.NET. If you have this requirement in practical applications, you can't try it.

'Autor: Lyxer

'Email: l_yx123@sina.com.cn

'Segment strings and get every content

Public function get_token (byref ssource as string, byval sseparator as string)

DIM P AS INTEGER

DIM SRET AS STRING

P = instr (ssource, sseparator)

IF P = 0 THEN

SRet = SSOource

SSOURE = "" "

Else

SRet = MID (SSOURE, 1, P - 1)

SSource = Right (SSOURCE, LEN (SSOURES) - P)

END IF

GET_TOKEN = SRET

END FUNCTION

When you are using, you have to pay attention, SSOource must be placed in a variable, do not set the caption of a space or try the TEXT attribute value, because this value is changing.

转载请注明原文地址:https://www.9cbs.com/read-12214.html

New Post(0)