-----------------------------------------------------------------
Public Function spacelen(cs As Variant, slen As Long)
Dim i As Long
Dim s() As Byte
'不使用len函数,是因为 中文字符宽度问题
s = StrConv(cs, vbFromUnicode)
i = UBound(s) + 1
If i < slen Then
spacelen = Space(slen - i) & cs
Else
spacelen = cs
End If
End Function
-----------------------------------------------------------------
Public Function spacelen(cs As Variant, slen As Long)
Dim i As Long
Dim s() As Byte
'不使用len函数,是因为 中文字符宽度问题
s = StrConv(cs, vbFromUnicode)
i = UBound(s) + 1
If i < slen Then
spacelen = Space(slen - i) & cs
Else
spacelen = cs
End If
End Function
----------------------------------
Public Function spacelen(cs As Variant, slen As Long) '在头添加空格以达到指定长度
Dim i As Long
Dim s() As Byte
'不使用len函数,是因为 中文字符宽度问题
s = StrConv(cs, vbFromUnicode)
i = UBound(s) + 1
If i < slen Then
spacelen = Space(slen - i) & cs '空格加到头
Else
spacelen = cs
End If
End Function
Public Function spacelenR(cs As Variant, slen As Long) '在尾添加空格以达到指定长度
Dim i As Long
Dim s() As Byte
'不使用len函数,是因为 中文字符宽度问题
s = StrConv(cs, vbFromUnicode)
i = UBound(s) + 1
If i < slen Then
spacelen = cs & Space(slen - i) '空格加到尾
Else
spacelen = cs
End If
End Function
----------------------------------
Public Function spacelen(cs As Variant, slen As Long) '在头添加空格以达到指定长度
Dim i As Long
Dim s() As Byte
'不使用len函数,是因为 中文字符宽度问题
s = StrConv(cs, vbFromUnicode)
i = UBound(s) + 1
If i < slen Then
spacelen = Space(slen - i) & cs '空格加到头
Else
spacelen = cs
End If
End Function
Public Function spacelenR(cs As Variant, slen As Long) '在尾添加空格以达到指定长度
Dim i As Long
Dim s() As Byte
'不使用len函数,是因为 中文字符宽度问题
s = StrConv(cs, vbFromUnicode)
i = UBound(s) + 1
If i < slen Then
spacelen = cs & Space(slen - i) '空格加到尾
Else
spacelen = cs
End If
End Function