limitations/specifications for the Format Function

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to use the format function to right-pad strings.

For instance, i have a string x that must have a length of 365 characters
(to match a custom data type). After a user enters a value for x (which may
not be 365 characters), i have to convert it to a string with a length of 365.

Here is an example:
dim t as string, sNew as string, s as string
's is obtained from a text box -
s="SELECT GPDate, GPTitle, GPCo FROM tblGPType Where GPType = 4 And GPCo =
Question('CoGrp') ORDER BY GPActDate DESC;"

t="!" & string(365,"@") 'creates a format template

sNew = format(s,t)

I expect sNew to be the same as s padded to the right with spaces to a
length of 365. However, what is returned is
"T GPDate, GPTitle, GPCo FROM tblGPType Where GPType = 4 And GPCo =
Question('CoGrp') ORDER BY GPActDate DESC; ........"

It has a length of 365, but several of the initial characters from the s
have been truncated.

I can't find any documentation that would explain this behaviour, but it
sure is giving me a headache.

Any one have an idea as to what is going on?

thanks
 
You don't need the format function here. all you need is:
sNew = s & Space(365 - Len(s))
 
thanks, i forgot about the space function - i can stop banging my head
against the wall now (luckily the cube walls are padded)
 
I wondered what that banging noise was on my cube wall. It was interfering
with my nap.
 
Back
Top