[AccessD] Re: This should be simple...but...

Robert L. Stewart rl_stewart at highstream.net
Fri Jan 30 12:53:58 CST 2004


Use a pad function to chance the text displayed and change the font to a 
mono-spaced font.

Here is the function.  Watch out for line wrap.

Function PadString(strText As String, intWidth As Integer, _
  strSide As String, Optional strPad As String = " ") As String

     ' Pad strText on either side, so the whole output is
     ' at least intWidth characters.
     ' If strText is longer than intWidth, just return strText.
     ' If strPad is wider than one character, this code only takes
     '  the first character for padding with it.
     ' Parameters:
     '   strText:
     '       Input text
     '   intWidth:
     '       Minimum width of the output. If
     '       Len(strText) < intWidth, then the
     '       output will be exactly intWidth characters
     '       wide. The code will not truncate strText,
     '       no matter what.
     '   strSide:
     '       This is either L or R for Left or Right
     '   strPad (Optional, default is " "):
     '       string whose first character will
     '       be used to pad the output.
     ' Returns:
     '   Return Value:
     '       strText, padded on the specified side with
     '       the first character of strPad.
     ' Example:
     '   PadString("Name", 10, "R", ".") returns
     '       "Name......"
     '

     If Len(strText) > intWidth Then
         PadString = strText
     End If
     If strSide = "R" Then
         PadString = Left$(strText & String(intWidth, strPad), intWidth)
     Else
         PadString = Right$(String(intWidth, strPad) & strText, intWidth)
     End If
End Function

This will not align text to the center, only left or right.

Paste this into a module, then in the immediate window
type ? PadString("Name", 10, "R", ".")
You should see Name......

Robert



At 12:00 PM 1/30/2004 -0600, you wrote:
>Date: Fri, 30 Jan 2004 09:22:42 -0500
>From: "John Clark" <John.Clark at niagaracounty.com>
>Subject: [AccessD] This should be simple...but...
>To: <accessd at databaseadvisors.com>
>Message-ID: <s01a22c0.021 at nebnov1.niagaracounty.com>
>Content-Type: text/plain; charset=US-ASCII
>
>On a form I am working on, I am trying to provide 'leading dots',
>between the label and text box. I want to make all labels equal by doing
>this, which means some will have more or less dots than others. I
>usually don't do this, because of what I am now experiencing; they don't
>all line up. They are slightly off, but enough to notice.
>
>EXAMPLE: (These are slightly off also)
>
>Name ....................:
>Address .................:
>City ........................:
>St ..........................:
>Zip .........................:
>
>Any ideas on this? Maybe even alternatives?
>
>Thanks,
>J Wallace Clark (Hey, this lawerese is kinda fun)




More information about the AccessD mailing list