|
快贴 & 骗贴
函数:Replace(Space(n), Space(1), str)
?Replace(Space(3), Space(1), "0")
000
'字符串自增函数
Function StrAdd(myStr As String, Optional parm As Integer = 1)
Dim strL As String, strR As String, formatStr As String
Dim L As Byte, m As Byte, n As Long
If Len(myStr & "") = 0 Then Exit Function
L = Len(myStr)
m = L
Do Until Mid(myStr, m, 1) Like "[!0-9]" '从右边截取有效数字
m = m - 1
If m = 0 Then Exit Do
Loop
If m = L Then
StrAdd = myStr
Else
formatStr = Replace(Space(L - m), Space(1), "0") '格式
strL = left(myStr, m) '左边
n = Right(myStr, L - m) + parm '新值
strR = Format(Right(n, L - m), formatStr) '右边
StrAdd = strL & strR
End If
End Function
?StrAdd("1d1",1)
1d2
|
|