Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
What's the easiest way to modify a string in a variable so that it only holds a maximum of 16 characters, and if it's less than 16 characters I want to attach asterisk "*" characters until it makes the string length 16?
Here are some before-after examples: BEFO s = "french fries" ' Len = 12 AFTER: s = "french fries****" ' Len = 16 BEFO s = "" ' Len = 0 AFTER: s = "****************" ' Len = 16 BEFO s = "tree" ' Len = 4 AFTER: s = "tree************" ' Len = 16 BEFO s = "There are fries." ' Len = 16 AFTER: s = "There are fries." ' Len = 16 The last example has 16 characters, so there's no need to pad it. I think I could do this simply in C/C++ with the printf() format string, but I'm looking for a quick way to do this with VBA. Thanks. -Robert |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Fixed length string of text | Excel Discussion (Misc queries) | |||
Public fixed length string variable | Excel Programming | |||
creating numbers to a fixed length string... | Excel Worksheet Functions | |||
fixed string length,even other record is copied | Excel Discussion (Misc queries) | |||
Sorted Fixed Length String | Excel Programming |