Move string with array

xiaoxiao2021-03-06  64

This is the mutual inverse function for string processing

Function: Move string

Using: Arymoveleft ("string", number of mobile

example:

DIM STRG

STRG = "123456789"

STRG = Arymoveleft (STRG, 2)

RESULTS: STRG = "345678912"

Public Function Arymoveleft (Str, Count)

If count = 0 THEN

Arymoveleft = STR

EXIT FUNCTION

END IF

DIM A ()

Strlen = LEN (STR)

Redim A (Strlen)

For i = 1 to Len (STR)

A (i) = MID (STR, I, 1)

NEXT

TEMP = a (1)

For i = 2 to Len (STR)

A (i - 1) = a (i)

NEXT

a (strlen) = TEMP

For i = 1 to Len (STR)

Result = Result & A (i)

NEXT

Arymoveleft = Arymoveleft (Result, Count - 1)

END FUNCTION

Public Function Arymoveright (Str, Count)

If count = 0 THEN

Arymoveright = STR

EXIT FUNCTION

END IF

DIM A ()

Strlen = LEN (STR)

Redim A (Strlen)

For i = 1 to Len (STR)

A (i) = MID (STR, I, 1)

NEXT

Temp = A (Strlen)

For i = len (str) to 2 Step -1

A (i) = a (i - 1)

NEXT

a (1) = TEMP

For i = 1 to Len (STR)

Result = Result & A (i)

NEXT

Arymoveright = arymoveright (Result, Count - 1)

END FUNCTION

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

New Post(0)