Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement string manipulation in vbs

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article is about how vbs implements string manipulation. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Str= "a | b | c | d"

Ask to write a paragraph on Mini Program and get:

A | b | c | d

B | c | d | a

C | d | a | b

D | a | b | c

As a result, the length of the str is uncertain and the format is the one above.

The implementation code is as follows:

The copy code is as follows:

Str= "a | b | c | d"

Call Sort (str, "|")

Function Sort (sSource, sDelimiter)

Dim I, J, N, sItems, sTemp

SItems = Split (sSource, sDelimiter)

For I = 0 To UBound (sItems)

For J = 0 To UBound (sItems)

N = I + J

If N > UBound (sItems) Then

N = N-UBound (sItems)-1

End If

STemp = sTemp & sItems (N) & sDelimiter

Next

STemp = Left (sTemp, Len (sTemp)-Len (sDelimiter))

Wscript.Echo sTemp

STemp = ""

Next

End Function

Display in one window at the same time

The copy code is as follows:

Str = "a | b | c | d"

WSH.Echo Join (Sort (str, "|"), vbCrLf)

Function Sort (ByVal s, ByVal d)

Dim a, r (), I, j, h, index

A = Split (s, d)

H = UBound (a)

ReDim Preserve r (h)

Index = Len (d) + 1

For I = 0 To h

R (I) = ""

For j = i To h + I

R (I) = r (I) & d & a (j Mod (h + 1))

Next

R (I) = Mid (r (I), index)

Next

Sort = r

End Function

The copy code is as follows:

Str= "a | b | c | d"

Wscript.Echo Sort (str, "|")

Function Sort (sSource, sDelimiter)

Dim I, J, N, sItems, sTemp

SItems = Split (sSource, sDelimiter)

N = UBound (sItems)

For I = 0 To N

For J = 0 To N

STemp = sTemp & sItems ((I + J) Mod (N + 1)) & sDelimiter

Next

STemp = Left (sTemp, Len (sTemp)-Len (sDelimiter))

Sort = Sort & sTemp & vbCrLf

STemp = ""

Next

Sort = Left (Sort, Len (Sort)-1)

End Function

The copy code is as follows:

Str= "a | b | c | d"

Msgbox Sort (str, "|")

Function sort (ss,sd)

Dim n,i

For iTun0 to ubound (split (ss,sd))

Sort=sort+mid (ss+sd+ss,n+1,len (ss)) + vbcrlf

N=instr (nasty 1thecontrolls, dancesd)

Next

End function

Thank you for reading! This is the end of this article on "how to manipulate strings in vbs". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report