Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default # of letters in a string


Is there anyway to tell how many letters are in a string? More
specifically, I have a userform where the user enters a string into a
textbox. The textbox will only accept a total of 10 letters. When the
string variable gets passed to my sub routine, I need to know how many
letters are in that string.

If I can determine how many letters are in the string, if there are
less than 10, I then want to add spaces to the end of that string to
make it 10 characters long.

For example, if I enter:
"August" (6 characters) - it will then change it to "August____" (_ =
" ")
"California" (10 characters) - it will not add any spaces


TIA for any help,

DejaVu


--
DejaVu
------------------------------------------------------------------------
DejaVu's Profile: http://www.excelforum.com/member.php...o&userid=22629
View this thread: http://www.excelforum.com/showthread...hreadid=393382

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default # of letters in a string

sStr = Left(sStr & " ",10)

--
Regards,
Tom Ogilvy


"DejaVu" wrote in
message ...

Is there anyway to tell how many letters are in a string? More
specifically, I have a userform where the user enters a string into a
textbox. The textbox will only accept a total of 10 letters. When the
string variable gets passed to my sub routine, I need to know how many
letters are in that string.

If I can determine how many letters are in the string, if there are
less than 10, I then want to add spaces to the end of that string to
make it 10 characters long.

For example, if I enter:
"August" (6 characters) - it will then change it to "August____" (_ =
" ")
"California" (10 characters) - it will not add any spaces


TIA for any help,

DejaVu


--
DejaVu
------------------------------------------------------------------------
DejaVu's Profile:

http://www.excelforum.com/member.php...o&userid=22629
View this thread: http://www.excelforum.com/showthread...hreadid=393382



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default # of letters in a string

msgbox len(sStr) gives the number of characters in the string held in
variable sStr (just for completeness)

--
Regards,
Tom Ogilvy

"DejaVu" wrote in
message ...

Is there anyway to tell how many letters are in a string? More
specifically, I have a userform where the user enters a string into a
textbox. The textbox will only accept a total of 10 letters. When the
string variable gets passed to my sub routine, I need to know how many
letters are in that string.

If I can determine how many letters are in the string, if there are
less than 10, I then want to add spaces to the end of that string to
make it 10 characters long.

For example, if I enter:
"August" (6 characters) - it will then change it to "August____" (_ =
" ")
"California" (10 characters) - it will not add any spaces


TIA for any help,

DejaVu


--
DejaVu
------------------------------------------------------------------------
DejaVu's Profile:

http://www.excelforum.com/member.php...o&userid=22629
View this thread: http://www.excelforum.com/showthread...hreadid=393382



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default # of letters in a string

Or you could do the following:

sStr = sStr & Space(10 - Len(sStr))

"Tom Ogilvy" wrote:

sStr = Left(sStr & " ",10)

--
Regards,
Tom Ogilvy


"DejaVu" wrote in
message ...

Is there anyway to tell how many letters are in a string? More
specifically, I have a userform where the user enters a string into a
textbox. The textbox will only accept a total of 10 letters. When the
string variable gets passed to my sub routine, I need to know how many
letters are in that string.

If I can determine how many letters are in the string, if there are
less than 10, I then want to add spaces to the end of that string to
make it 10 characters long.

For example, if I enter:
"August" (6 characters) - it will then change it to "August____" (_ =
" ")
"California" (10 characters) - it will not add any spaces


TIA for any help,

DejaVu


--
DejaVu
------------------------------------------------------------------------
DejaVu's Profile:

http://www.excelforum.com/member.php...o&userid=22629
View this thread: http://www.excelforum.com/showthread...hreadid=393382




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default # of letters in a string


Thanks to both of you... your help is much appreciated.

DejaV

--
DejaV
-----------------------------------------------------------------------
DejaVu's Profile: http://www.excelforum.com/member.php...fo&userid=2262
View this thread: http://www.excelforum.com/showthread.php?threadid=39338

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formatting string in groups of letters... HBj[_2_] Excel Worksheet Functions 8 March 6th 09 03:49 PM
Breaking a string of letters Confused Excel Discussion (Misc queries) 2 March 10th 07 11:49 AM
Breaking a string of letters john Excel Discussion (Misc queries) 0 March 8th 07 07:31 PM
Calculating number of letters in a string ... Larry Wallis Excel Discussion (Misc queries) 4 February 17th 05 10:11 AM
Calculating number of letters in a string ... Larry Wallis Excel Worksheet Functions 4 February 17th 05 10:11 AM


All times are GMT +1. The time now is 02:00 AM.

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

About Us

"It's about Microsoft Excel"