If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
limitations/specifications for the Format Function
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 -- dchman |
#2
|
|||
|
|||
limitations/specifications for the Format Function
You don't need the format function here. all you need is:
sNew = s & Space(365 - Len(s)) "dchman" wrote: 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 -- dchman |
#3
|
|||
|
|||
limitations/specifications for the Format Function
thanks, i forgot about the space function - i can stop banging my head
against the wall now (luckily the cube walls are padded) -- dchman "Klatuu" wrote: You don't need the format function here. all you need is: sNew = s & Space(365 - Len(s)) "dchman" wrote: 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 -- dchman |
#4
|
|||
|
|||
limitations/specifications for the Format Function
I wondered what that banging noise was on my cube wall. It was interfering
with my nap. "dchman" wrote: thanks, i forgot about the space function - i can stop banging my head against the wall now (luckily the cube walls are padded) -- dchman "Klatuu" wrote: You don't need the format function here. all you need is: sNew = s & Space(365 - Len(s)) "dchman" wrote: 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 -- dchman |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
determine if Excel is open | geebee | General Discussion | 11 | January 20th, 2006 09:25 PM |
Format function not working in queries? | lwert | Running & Setting Up Queries | 1 | October 12th, 2005 05:48 AM |
Function for reading cell format | msbaby | Worksheet Functions | 2 | October 6th, 2004 01:55 PM |
email format | Lloyd | General Discussion | 1 | June 16th, 2004 03:42 AM |
Return a format by VBA function | Titoun | Worksheet Functions | 1 | January 7th, 2004 07:15 PM |