来个简单的: Function twiceStr(ByVal bStr As String) As String ''输入 2*7+6*5==>4*14+12*10 If Len(Trim(bStr)) = 0 Then Exit Function Dim i As Long, w1 As String, w2 As String, w3 As String For i = 1 To Len(bStr) w2 = Mid$(bStr, i, 1) If InStr("0123456789", w2) > 0 Then w3 = w3 & w2 Else If w3 <> "" Then w1 = w1 & CStr(Val(w3) * 2) w1 = w1 & w2 w3 = "" End If Next If w3 <> "" Then w1 = w1 & CStr(Val(w3) * 2) twiceStr = w1 End Function
Function twiceStr(ByVal bStr As String) As String
''输入 2*7+6*5==>4*14+12*10
If Len(Trim(bStr)) = 0 Then Exit Function
Dim i As Long, w1 As String, w2 As String, w3 As String
For i = 1 To Len(bStr)
w2 = Mid$(bStr, i, 1)
If InStr("0123456789", w2) > 0 Then
w3 = w3 & w2
Else
If w3 <> "" Then w1 = w1 & CStr(Val(w3) * 2)
w1 = w1 & w2
w3 = ""
End If
Next
If w3 <> "" Then w1 = w1 & CStr(Val(w3) * 2)
twiceStr = w1
End Function