我需要将此号码309701406
拆分为30
970
140
6
。我怎么能用VB宏脚本。任何一个请看这个和协助。
答案 0 :(得分:4)
如您对问题的评论中所述,您可以使用以下内容:
SomeString = Mid(StringName, Start, Length)
将其放入Sub
将如下所示:
Option Explicit
Sub SplitStringSub()
Dim OriginalString As String
Dim String1 As String
Dim String2 As String
Dim String3 As String
Dim String4 As String
OriginalString = 309701406
'Mid wants a String input
'Because of the need to split the Numerical String it is not explicity required to have the " " around then String input line.
'Should you want to Split a String of Alphabetical Characters the " " will definitely be required.
String1 = Mid(OriginalString, 1, 2)
String2 = Mid(OriginalString, 3, 3)
String3 = Mid(OriginalString, 6, 3)
String4 = Mid(OriginalString, 9, 1)
End Sub
答案 1 :(得分:1)
如果0是分隔符,则可以执行此操作。
Dim str As String
Dim aTmp() As String
str = "309701406"
aTmp() = Split(str, "0")
str = Join(aTmp, "0 ")
aTmp() = Split(str, " ")