A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

function needed



 
 
Thread Tools Display Modes
  #1  
Old September 10th, 2004, 11:09 AM
alekm
external usenet poster
 
Posts: n/a
Default function needed

Hi,
is there a function in VBA that can do following:
I want to specify string X, char A , and length N of resultant string.
Function should fill string X from left with char A so resultant string would
be N long.
eg. F('abc','x', 6) = 'xxxabc'
Thanx
alekmil
  #2  
Old September 10th, 2004, 11:53 AM
Arvin Meyer
external usenet poster
 
Posts: n/a
Default

This is similar to the older LPad function which was part of the
NeatCode.mdb distributed years ago for Access 2.0:

Function LeftFill(strIn As String, ByVal strChr As String, intCount As
Integer) As String

' Adds a character (strChr) to the left of strIn to make it right justified
' by intCount characters
On Error Resume Next

If Len(strChr) = 0 Then strChr = " "
If intCount 1 Then
LeftFill = ""
Else
LeftFill = Right(String(intCount, Left(strChr, 1)) & strIn, intCount)
End If

End Function
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access

"alekm" wrote in message
...
Hi,
is there a function in VBA that can do following:
I want to specify string X, char A , and length N of resultant string.
Function should fill string X from left with char A so resultant string

would
be N long.
eg. F('abc','x', 6) = 'xxxabc'
Thanx
alekmil



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help needed with Function Yogi Watcher General Discussion 2 July 8th, 2004 07:13 PM
Excel Function help needed please! CRWJumper Worksheet Functions 2 March 11th, 2004 12:50 PM
My own function cannot be exported. Christian Worksheet Functions 0 November 26th, 2003 03:22 PM
Keeping a Function Cell Blank Until It's Needed barry a Worksheet Functions 1 September 26th, 2003 06:41 PM


All times are GMT +1. The time now is 09:14 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.