Board index » Visual Studio » Format Command

Format Command

Visual Studio280
I've inherited a project from a programmer who is no longer available. It

contains the command



Format(name, "!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")



This statement is trimming the first 2 characters from the name. I can find

no reference to the symbols used in the format string.



What was the programmer trying to accomplish with this syntax?


-
 

Re:Format Command

"Paul Nations" <pauln@adhe.arknet.nospam.edu>wrote in message

Quote
I've inherited a project from a programmer who is no longer

available. It contains the command



Format(name, "!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")



This statement is trimming the first 2 characters from the name. I

can find no reference to the symbols used in the format string.



What was the programmer trying to accomplish with this syntax?





left-justified; 35 characters wide



-

Re:Format Command

It is stripping the first 2 characters from the name. So that 'Smith, John

D.' becomes 'ith, John D.'



Any ideas on what could I replace that format string with so that the next

time this code is looked at the programmer won't have to go searching all

over the place for a clue as to it's intent?





"Bob Butler" <tiredofit@nospam.com>wrote in message

Quote
"Paul Nations" <pauln@adhe.arknet.nospam.edu>wrote in message

news:uaTbH25TDHA.2088@TK2MSFTNGP10.phx.gbl

>I've inherited a project from a programmer who is no longer

>available. It contains the command

>

>Format(name, "!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")

>

>This statement is trimming the first 2 characters from the name. I

>can find no reference to the symbols used in the format string.

>

>What was the programmer trying to accomplish with this syntax?





left-justified; 35 characters wide







-

Re:Format Command

"Paul Nations" <pauln@adhe.arknet.nospam.edu>wrote in message

Quote
It is stripping the first 2 characters from the name. So that

'Smith, John D.' becomes 'ith, John D.'



Any ideas on what could I replace that format string with so that the

next time this code is looked at the programmer won't have to go

searching all over the place for a clue as to it's intent?



Is the string being formatted padded with spaces?



My choice would probably be something like:

Left$(Trim$(name) & space$(35),35)







-

Re:Format Command

Yes. It would appear the programmer wanted it exactly 35 chars long. It's

being output to a printer with Courier font.

I think your command is the best solution to let the next guy who opens this

thing (hopefully me) know what's going on.



Thanks so much.





"Bob Butler" <tiredofit@nospam.com>wrote in message

Quote
"Paul Nations" <pauln@adhe.arknet.nospam.edu>wrote in message

news:uxcFNE6TDHA.1724@TK2MSFTNGP10.phx.gbl

>It is stripping the first 2 characters from the name. So that

>'Smith, John D.' becomes 'ith, John D.'

>

>Any ideas on what could I replace that format string with so that the

>next time this code is looked at the programmer won't have to go

>searching all over the place for a clue as to it's intent?



Is the string being formatted padded with spaces?



My choice would probably be something like:

Left$(Trim$(name) & space$(35),35)











-

Re:Format Command

Did you get that from the top of this thread?? :-)



--

Veign

Chris Hanscom

www.veign.com">www.veign.com

Application Design Section

www.veign.com/information/application/info_app.html">www.veign.com/information/application/info_app.html

------

"steve hotmail.com>" <stesrc@<remove.this.antispam.bit>wrote in message

Quote


How about something like this



' this formats the string to be exactly 35 chrs wide

Format(name, "!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")







steve





On Mon, 21 Jul 2003 11:08:25 -0500, "Paul Nations"

<pauln@adhe.arknet.nospam.edu>wrote:



>Yes. It would appear the programmer wanted it exactly 35 chars long.

It's

>being output to a printer with Courier font.

>I think your command is the best solution to let the next guy who opens

this

>thing (hopefully me) know what's going on.

>

>Thanks so much.

>

>

>"Bob Butler" <tiredofit@nospam.com>wrote in message

>news:emGASH6TDHA.1912@tk2msftngp13.phx.gbl...

>>"Paul Nations" <pauln@adhe.arknet.nospam.edu>wrote in message

>>news:uxcFNE6TDHA.1724@TK2MSFTNGP10.phx.gbl

>>>It is stripping the first 2 characters from the name. So that

>>>'Smith, John D.' becomes 'ith, John D.'

>>>

>>>Any ideas on what could I replace that format string with so that the

>>>next time this code is looked at the programmer won't have to go

>>>searching all over the place for a clue as to it's intent?

>>

>>Is the string being formatted padded with spaces?

>>

>>My choice would probably be something like:

>>Left$(Trim$(name) & space$(35),35)

>>

>>

>>

>







-

Re:Format Command

Quote
I've inherited a project from a programmer who is no longer available. It

contains the command



Format(name, "!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")



This statement is trimming the first 2 characters from the name. I can

find

no reference to the symbols used in the format string.



What was the programmer trying to accomplish with this syntax?



This form of the Format function **is** documented; it's just not as easy to

find as it should be. Look up "Format function" (no quotes) in the help

files; click on the "See Also" link; scroll down to the bottom where it

says "User-Defined String Formats (Format Function)" and click it. The

meta-characters you asked about are described there along with some others.



By the way, I'd probably have shortened the above to



Format$(name, "!" & String(35, "@"))



Rick - MVP





-

Re:Format Command

On Mon, 21 Jul 2003 13:09:29 -0400, "Veign" <NOSPAMinveign@veign.com>

wrote:



Quote
Did you get that from the top of this thread?? :-)



Nope! It came to me in what could be described as a rare moment of

clarity <g>





-

Re:Format Command

"Paul Nations" <pauln@adhe.arknet.nospam.edu>wrote

Quote
Yes. It would appear the programmer wanted it exactly 35 chars long. It's

being output to a printer with Courier font.

I think your command is the best solution to let the next guy who opens this

thing (hopefully me) know what's going on.



Thanks so much.











-

Re:Format Command

"Paul Nations" <pauln@adhe.arknet.nospam.edu>wrote in message

Quote
Yes. It would appear the programmer wanted it exactly 35 chars long. It's

being output to a printer with Courier font.

I think your command is the best solution to let the next guy who opens this

thing (hopefully me) know what's going on.







Oops, hit send on an empty message! :-P



I just wanted to add that one of the advantages of an extendable language

is that you can make it so your intentions are clear, even when the language

to do so may be obscure:



Printer.Print LeftAlign(CustName, 35)



There would be very little guesswork about what that might mean. And just

for completeness, here are two candidates for LeftAlign and RightAlign:





Public Function LeftAlign(ByRef Text, Optional Length As Long = 0) As String

Length = Abs(Length)

If Length = 0 Then Length = Len(Text)

LeftAlign = Left$(LTrim$(Text) & Space$(Length), Length)

End Function



Public Function RightAlign(ByRef Text, Optional Length As Long = 0) As String

Length = Abs(Length)

If Length = 0 Then Length = Len(Text)

RightAlign = Right$(Space$(Length) & RTrim$(Text), Length)

End Function





HTH

LFS









-