'定长字符串
'FixedLengthText(字符,长度,对齐=0)
'对齐方式 ' 0 左  1中  2 右
Function FixedLengthText(nText as String , nLen as Long, nD as Long =0) as String'定长字符串
' 0 左  1中  2 右
   Dim as Integer byu,L,H,a,I
   byu=Len(nText)
   If byu > nLen Then
        If nLen < 4 Then
            Function = String(nLen, ".")
        Else
            For i=1 To nLen-2
                If Asc(nText,i)>126 Then a +=1
            Next
            If a Mod 2 =0 Then '中文
                Function = Left(nText,nLen-2) & toStr("..")
            Else
                Function = Left(nText,nLen-3) & toStr("...")
             End If
        End If
    Else
        Select Case nD '对齐方式 ' 0 左  1中  2 右
            Case 0
                Function=nText &  Space(nLen - byu)           
            Case 1
                L = Int((nLen - byu) / 2)
                H = nLen-byu-L
                Function = Space(L) & nText &  Space(H)   
            Case 2
                Function=Space(nLen - byu) & nText   
        End Select
   End If
End Function