大家试试
format("111011101110000101010011100011","00000000000000000000000000000000")我得到的是00111011101110000000000000000000不解中.忘高手解答! 谢谢
format("111011101110000101010011100011","00000000000000000000000000000000")我得到的是00111011101110000000000000000000不解中.忘高手解答! 谢谢
其他的都行,就是这个有问题,是不是太特殊了?
如果只是测试这个函数,都可以试下
如果真得用Format函数做这个,好像没有意义
对于字符串补齐这样简单规则没必要用format,因为format内部有一大堆的转换规则,一来效率不高二来有这样那样的限制。自己写一个函数处理很简单的'字符串补位函数
'strInput 需要处理的字符串 intFillLen补齐后长度 strFillString补位字符 blnFillBefore是否在前面补位
Private Function test(strInput As String, intFillLen As Integer, strFillString As String, Optional blnFillBefore As Boolean = True) As String
If intFillLen < Len(strInput) Then test = strInput: Exit Function
If blnFillBefore Then
test = String(intFillLen - Len(strInput), strFillString) & strInput
Else
test = strInput & String(intFillLen - Len(strInput), strFillString)
End If
End Function调用举例
Dim a As String
a = "111011101110000101010011100011"
Debug.Print test(a, 32, "0")
Debug.Print test(a, 32, "E", False)输出
00111011101110000101010011100011
111011101110000101010011100011EE