一个补0的格式函数
Function AFormat(ByVal sStr As String, ByVal sFormat As String) As String
'作者:朱亦文
'日期:2004-7-21
Dim sF() As String
Dim sS() As String
Dim i As Integer, j As Integer, k As Integer
sF = Split(sFormat, "-")
i = UBound(sF)
sS = Split(sStr, "-")
j = UBound(sS)
ReDim Preserve sS(i + 1)
For k = j + 1 To i
sS(k) = sF(k)
Next
For k = 0 To i
sS(k) = Format(sS(k), sF(k))
Next
AFormat = Join(sS, "-")
AFormat = Left(AFormat, Len(AFormat) - 1)
End Function
=========================================
例:
AFormat("4-723-23-1-1", "00-0000-000-000-000")
04-0723-023-001-001