[英]Split a String - Vba based on symbols
I have a string like this ABC$3$FG$H
and I want to split them into 4 different strings. 我有一个像ABC$3$FG$H
这样的字符串,我想将它们分成4个不同的字符串。
string1 - ABC, Number-3, string3-FG, String4 - H.
I am splitting the string with $ sign in the actual string. 我在实际的字符串中用$符号分割字符串。
Split(String1,"$")
Quite enough. 足够了。 Returns a zero-based, one-dimensional array containing a specified number of substrings. 返回包含指定数量子字符串的从零开始的一维数组。
If you want to look through the splitted string, this is a possible solution: 如果您想查看拆分字符串,这是一个可能的解决方案:
Public Sub TestMe()
Dim str As String
Dim cnt As Long
str = "ABC$3$FG$H"
For cnt = LBound(Split(str, "$")) To UBound(Split(str, "$"))
Debug.Print Split(str, "$")(cnt)
Next cnt
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.