-1

我发现了很多关于如何填充字符串的建议,Access 2010但没有找到关于如何将带有空格的可变长度字符串填充到预定的总字符串长度的建议。

例子:

Total length = 55, 
if string len = 15, then pad " " x 40 (15+40=55)
if string len = 35, then pad " " x 20 (35+20=55) etc  

我可以编写一个函数来做到这一点,但我想知道是否已经内置了一个!

4

3 回答 3

1

有点数学?

 [x] & space(55 - len([x]))
于 2016-03-07T15:11:01.403 回答
0

有一个本机功能:

Dim Total   As String
Dim Content As String

Total = Space(55)
Content = "Some Content"
RSet Total = Content

Debug.Print Chr(34) & Total & Chr(34)
' Will return:
' "Some Content                                           "

甚至更简单:

Dim Total   As String * 55
Dim Content As String

Content = "Some Content"
RSet Total = Content

Debug.Print Chr(34) & Total & Chr(34)
' Will return:
' "Some Content                                           "
于 2016-03-08T07:44:41.000 回答
0
SELECT 
(MyTest.[Name1]) & SPACE(55-LEN(MyTest.[Name1])) + 
(MyTest.[Name2]) & SPACE(55-Nz(LEN(MyTest.[Name2]), 0)) + 
(MyTest.[Name3]) & SPACE(55-LEN(MyTest.[Name3])) 
FROM MyTest; 
于 2016-03-10T09:25:48.290 回答