View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Mervyn Thomas Mervyn Thomas is offline
external usenet poster
 
Posts: 44
Default Fixed Length Text fields

That's perfect!
Mervyn
"Executor" wrote in message
oups.com...
Hi Mervin,

I have created a common function:

Public Function RightPad(ByVal sOriginal As String, ByVal iLength As
Integer) As String
If Len(sOriginal) < iLength Then
RightPad = sOriginal & Space(iLength - Len(sOriginal))
Else
RightPad = Left(sOriginal, iLength)
End If
End Function

It takes 2 parameters:
1) The string
2) The length it must have.

If it is shorter some spaces will be added at the end.
If if is to long it will be truncated at the given length.

HTH.


Executor