473,326 Members | 2,655 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

limiting number of characters - pad

Thanks in advance... I have a string that I'm building that needs to
write to a file the last name, first name and middle initial in this
format with a maximum of 20 characters. Two examples:

Brenda J Lanier
Lanier,Brenda J

' note that this name is only 15 characters, with the space and
comma, after formatting so I'm safe

Edward M Berksweller:
Berksweller,Garrett M

' note that this name has 21 characters, with the space and comma,
so to stay within the 20 char limit it needs to write as:
Berksweller,Garrett
with the space being the 20th character... it's OK for me to loose the
middse initial

My best guess is this for the code:

FieldString = (emp.LastName & "," & emp.FirstName & "
" & emp.MI)
EmpList.Write(FieldString.PadRight(20, " "c))

But I don't think this will work. Any ideas? thanks!!!


Oct 15 '08 #1
1 1808
On Wed, 15 Oct 2008 12:56:56 -0700 (PDT), Brock <wa********@yahoo.com>
wrote:
>Thanks in advance... I have a string that I'm building that needs to
write to a file the last name, first name and middle initial in this
format with a maximum of 20 characters. Two examples:

Brenda J Lanier
Lanier,Brenda J

' note that this name is only 15 characters, with the space and
comma, after formatting so I'm safe

Edward M Berksweller:
Berksweller,Garrett M

' note that this name has 21 characters, with the space and comma,
so to stay within the 20 char limit it needs to write as:
Berksweller,Garrett
with the space being the 20th character... it's OK for me to loose the
middse initial

My best guess is this for the code:

FieldString = (emp.LastName & "," & emp.FirstName & "
" & emp.MI)
EmpList.Write(FieldString.PadRight(20, " "c))

But I don't think this will work. Any ideas? thanks!!!
Your explanation of what you want is confusing, and it didn't help
that you used an example in which the middle initial just put you over
the 20 character limit.

If your requirement is to use the first 20 characters of
"lastname,firstname m" regardless of where the break occurs in the
name (what if the last name is 20 chars, or if the 20 character
limit is in the middle of the first name?), then:

FieldString = (emp.LastName & "," & emp.FirstName & " " & emp.MI)
EmpList.Write(FieldString.PadRight(20).SubString(0 , 20))
Oct 16 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Sims | last post by:
Hi, I know how to limit the number of characters using substr, (http://uk.php.net/manual/en/function.substr.php). But when using html that is not going to work because of all the possible tags,...
5
by: Otto Krüse | last post by:
Hi everyone, I'm building a GUI in which I want, amongst other things, for people to fill in there postal code. The postal codes of my country (Holland) are in this format: 1234 AB So for the...
18
by: OrenFlekser | last post by:
Hi I've posted this message couple of days ago, but I can't find it now, so sorry if you see it twice... Anyways - I have a text box, and I want my users to be able to write only in english...
2
by: Jo Davis | last post by:
access fe and access be. later the be might be sql server I don't want people to pass this application around. And I want control over usage. I want it to 'expire' after a while. I have fairly...
2
by: Gerry Abbott | last post by:
Hi all, Im using an ubound form and recordsets for data update. Id like to trap invalid entries on this form. How can i limit the number of characters the user enters for a particular field. ? ...
4
by: N J | last post by:
Hi, I ahve developed a program using access and am distributing it using MDE's, I ahve had many requests for a demo. I was thinking of limiting the number of records to say 100? If anyone has...
4
by: GregG | last post by:
Greetings, I have been working with the new GridView control, and while figuring out most of it's idiosyncrasies on my own, have stumbled upon a problem I cannot seem to resolve. We have...
3
by: Bob Alston | last post by:
What do others do to limit the number of characters a user can enter in a text box? Do you specify the number of characters exactly so that only that number will fit in the text box, thereby...
2
by: prakashwadhwani | last post by:
I've used Dbase/Clipper for years & Access for a little while now but Access doesn't seem to have any elegant solution to limiting the size of a text box ... i.e. the max number of characters that...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.