Private Sub Command2_Click() Dim a As Stringa = "10203040" a = Replace(a, "0", "0,") a = Mid(a, 1, Len(a) - 1) MsgBox aEnd Sub
Dim a() As String a = Split("10203040", "0") For i = 0 To UBound(a) Form1.Print a(i) Next
如果两位一个的话 用mid函数取好了 Dim str, a, b, c, d As String str = "10203040" a = Mid(str, 1, 2) b = Mid(str, 3, 2) c = Mid(str, 5, 2) d = Mid(str, 7, 2)
Option ExplicitPrivate Sub Command1_Click() Dim S As String Dim i As Long S = "10203040" For i = 1 To Len(S) Step 2 Debug.Print Mid(S, i, 2) Next End Sub
Private Sub Command2_Click() Dim a As Stringa = "10203040" a = Replace(a, "0", "0,") a = Mid(a, 1, Len(a) - 1) MsgBox aEnd Sub同意这个比较快
楼上测试过吗? Option Explicit Private Declare Function GetTickCount Lib "kernel32" () As LongPrivate Sub Command2_Click() Dim A As String Dim t As Long Dim i As Long t = GetTickCount
For i = 1 To 100000 A = "10203040" A = Replace(A, "0", "0,") A = Mid(A, 1, Len(A) - 1) Next MsgBox A & " " & GetTickCount - t End SubPrivate Sub Command1_Click() Dim S As String Dim A As String Dim i As Long Dim j As Long Dim t As Long t = GetTickCount
For j = 1 To 100000 S = "10203040" A = "" For i = 1 To Len(S) Step 2 A = A & "," & Mid(S, i, 2) Next Next MsgBox A & " " & GetTickCount - t End Sub
Dim Arrary() As String,i As Integer,strTemp As String strTemp="10203040" strTemp = Replace(strTemp, "0", "0,") Arrary = Split(strTemp,",") For i = LBound(Arrary) To UBound(Arrary) Print Arrary(i) Next i
Dim a As Stringa = "10203040"
a = Replace(a, "0", "0,")
a = Mid(a, 1, Len(a) - 1)
MsgBox aEnd Sub
a = Split("10203040", "0")
For i = 0 To UBound(a)
Form1.Print a(i)
Next
用mid函数取好了
Dim str, a, b, c, d As String
str = "10203040"
a = Mid(str, 1, 2)
b = Mid(str, 3, 2)
c = Mid(str, 5, 2)
d = Mid(str, 7, 2)
Dim S As String
Dim i As Long
S = "10203040"
For i = 1 To Len(S) Step 2
Debug.Print Mid(S, i, 2)
Next
End Sub
Dim a As Stringa = "10203040"
a = Replace(a, "0", "0,")
a = Mid(a, 1, Len(a) - 1)
MsgBox aEnd Sub同意这个比较快
Option Explicit
Private Declare Function GetTickCount Lib "kernel32" () As LongPrivate Sub Command2_Click()
Dim A As String
Dim t As Long
Dim i As Long
t = GetTickCount
For i = 1 To 100000
A = "10203040"
A = Replace(A, "0", "0,")
A = Mid(A, 1, Len(A) - 1)
Next
MsgBox A & " " & GetTickCount - t
End SubPrivate Sub Command1_Click()
Dim S As String
Dim A As String
Dim i As Long
Dim j As Long
Dim t As Long
t = GetTickCount
For j = 1 To 100000
S = "10203040"
A = ""
For i = 1 To Len(S) Step 2
A = A & "," & Mid(S, i, 2)
Next
Next
MsgBox A & " " & GetTickCount - t
End Sub
strTemp="10203040"
strTemp = Replace(strTemp, "0", "0,")
Arrary = Split(strTemp,",")
For i = LBound(Arrary) To UBound(Arrary)
Print Arrary(i)
Next i