RSet和固定长度字符串 [英] RSet and Fixed Length Strings

查看:69
本文介绍了RSet和固定长度字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的项目中使用下面的代码。当我打印所有这些固定的

长度的字符串变量时,每行一个,他们在问题中的字符串没有用bs正确填充0。 strQuantity打印为 4英寸;.比intQuantity的

值多六个空格。这是正确的。


但是所有其他人最终都只是6个字符的字符串对象

(strTotal除外)。字符串

对象的最左侧位置用一个太少的空格填充。这怎么可能?


Dim curTicketPrice As Currency

Dim strTicketPrice As String * 7

Dim intQuantity As Integer

Dim strQuantity As String * 7

Dim curFee As Currency

Dim strFee As String * 7

Dim curSubtotal As Currency

Dim strSubtotal As String * 7

Dim curDiscount As Currency

Dim strDiscount As String * 7

Dim curTaxes As货币

Dim strTaxes As String * 7

Dim curTotal As Currency

Dim strTotal As String * 7


intQuantity = 4

curTicketPrice = 150.00

curFee = 30.00

curSubtotal = 630.00

curDiscount = 60.00

curTaxes = 85.80

curTotal = 655.50

RSet strQuantity = Format(intQuantity," General Number")

RSet strTicketPrice =格式(curTicketPrice,fixed)

RSet strFee =格式(curFee,fixed&q uot;)

RSet strSubtotal =格式(curSubtotal,fixed)

RSet strDiscount =格式(curDiscount,fixed)

RSet strTaxes =格式(curTaxes,fixed)

RSet strTotal =格式(curTotal,currency)


< ; Ade

-

Adrian Parker。被任命的牧师。 < ad *********** @ sympatico.ca>

想知道生活的目的吗?我很乐意与你分享......

I''m using the code below in my project. When I print all of these fixed
length string variables, one per line, they strings in questions do not
properly pad with 0s. strQuantity prints as " 4". Six spaces than the
value of intQuantity. This is correct.

But all the others end up being string objects of only 6 characters long
(with the exception of strTotal). The left most positions of the string
object are being padded with one too few spaces. How is this possible?

Dim curTicketPrice As Currency
Dim strTicketPrice As String * 7
Dim intQuantity As Integer
Dim strQuantity As String * 7
Dim curFee As Currency
Dim strFee As String * 7
Dim curSubtotal As Currency
Dim strSubtotal As String * 7
Dim curDiscount As Currency
Dim strDiscount As String * 7
Dim curTaxes As Currency
Dim strTaxes As String * 7
Dim curTotal As Currency
Dim strTotal As String * 7

intQuantity = 4
curTicketPrice = 150.00
curFee = 30.00
curSubtotal = 630.00
curDiscount = 60.00
curTaxes = 85.80
curTotal = 655.50

RSet strQuantity = Format(intQuantity, "General Number")
RSet strTicketPrice = Format(curTicketPrice, "fixed")
RSet strFee = Format(curFee, "fixed")
RSet strSubtotal = Format(curSubtotal, "fixed")
RSet strDiscount = Format(curDiscount, "fixed")
RSet strTaxes = Format(curTaxes, "fixed")
RSet strTotal = Format(curTotal, "currency")


<Ade
--
Adrian Parker. Ordained priest. <ad***********@sympatico.ca>
Want to know the purpose of life? I''d be happy to share it with you...

推荐答案

当我尝试你的代码时,它对我来说是正确的。当我打印出

变量时,每个变量都打印出7个字符。你是否

忘记与其他角色一起计算小数点?


Rick - MVP

" Adrian Parker" ; < no@addy.com>在消息中写道

新闻:Bq ******************* @ news20.bellglobal.com ..。
When I tried your code, it looked correct to me. When I printed the
variables out, each one printed out exactly 7 characters. Are you perhaps
forgetting to count the decimal point along with the other characters?

Rick - MVP
"Adrian Parker" <no@addy.com> wrote in message
news:Bq*******************@news20.bellglobal.com.. .
我在我的项目中使用下面的代码。当我打印所有这些固定的长度字符串变量时,每行一个,它们在问题中的字符串不能正确填充0。 strQuantity打印为 4英寸;. 6个空格比
值为intQuantity。这是正确的。

但所有其他人最终都是长度只有6个字符的字符串对象
(strTotal除外)。字符串
对象的最左侧位置用一个太少的空格填充。这怎么可能?

昏暗的curTicket价格作为货币
昏暗的strTicketPrice As String * 7
Dim intQuantity as Integer
Dim strQuantity As String * 7
Dim curFee as Currency
Dim strFee As String * 7
Dim curSubtotal As Currency
Dim strSubtotal As String * 7
Dim curDiscount As Currency
Dim strDiscount As String * 7
Dim curTaxes as Currency
Dim strTaxes As String * 7
Dim curTotal as Currency
Dim strTotal As String * 7

intQuantity = 4
curTicketPrice = 150.00
curFee = 30.00
curSubtotal = 630.00
curDiscount = 60.00
curTaxes = 85.80
curTotal = 655.50

RSet strQuantity = Format (intQuantity,General Number)
RSet strTicketPrice =格式(curTicketPrice,fixed)
RSet strFee =格式(curFee,fixed)
RSet strSubtotal =格式(curSubtotal,fixed)
RSet strDiscount =格式(curDiscount,fixed)
RSet strTaxes =格式(curTaxes,fixed)
RSet strTotal =格式(curTotal,currency)


< Ade
-
Adrian Parker。被任命的牧师。 < ad *********** @ sympatico.ca>
想知道生活的目的吗?我很乐意与你分享......
I''m using the code below in my project. When I print all of these fixed
length string variables, one per line, they strings in questions do not
properly pad with 0s. strQuantity prints as " 4". Six spaces than the value of intQuantity. This is correct.

But all the others end up being string objects of only 6 characters long
(with the exception of strTotal). The left most positions of the string
object are being padded with one too few spaces. How is this possible?

Dim curTicketPrice As Currency
Dim strTicketPrice As String * 7
Dim intQuantity As Integer
Dim strQuantity As String * 7
Dim curFee As Currency
Dim strFee As String * 7
Dim curSubtotal As Currency
Dim strSubtotal As String * 7
Dim curDiscount As Currency
Dim strDiscount As String * 7
Dim curTaxes As Currency
Dim strTaxes As String * 7
Dim curTotal As Currency
Dim strTotal As String * 7

intQuantity = 4
curTicketPrice = 150.00
curFee = 30.00
curSubtotal = 630.00
curDiscount = 60.00
curTaxes = 85.80
curTotal = 655.50

RSet strQuantity = Format(intQuantity, "General Number")
RSet strTicketPrice = Format(curTicketPrice, "fixed")
RSet strFee = Format(curFee, "fixed")
RSet strSubtotal = Format(curSubtotal, "fixed")
RSet strDiscount = Format(curDiscount, "fixed")
RSet strTaxes = Format(curTaxes, "fixed")
RSet strTotal = Format(curTotal, "currency")


<Ade
--
Adrian Parker. Ordained priest. <ad***********@sympatico.ca>
Want to know the purpose of life? I''d be happy to share it with you...



不,我算上了小数点。


例如,其中一项产出是 23.63" ;.空间后,一个空格,五个字符

。这是一个固定长度为7的String对象。

Adrian


" Rick Rothstein" < RI ************ @ NOSPAMcomcast.net>在消息中写道

新闻:CY ******************** @ comcast.com ...
No, I counted the decimal point.

One of the outputs, for example, is " 23.63". One space, five characters
after the space. And this is a String object with a fixed length of 7.
Adrian


"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message
news:CY********************@comcast.com...
当我试过你的代码,看起来对我来说是正确的。当我打印出
变量时,每个变量都打印出7个字符。您是否忘记将小数点与其他角色一起计算?

Rick - MVP

" Adrian Parker" < no@addy.com>在消息中写道
新闻:Bq ******************* @ news20.bellglobal.com ..。
When I tried your code, it looked correct to me. When I printed the
variables out, each one printed out exactly 7 characters. Are you perhaps
forgetting to count the decimal point along with the other characters?

Rick - MVP
"Adrian Parker" <no@addy.com> wrote in message
news:Bq*******************@news20.bellglobal.com.. .
我是在我的项目中使用以下代码。当我打印所有这些固定的长度字符串变量时,每行一个,它们在问题中的字符串不能正确填充0。 strQuantity打印为 4英寸;.除
I''m using the code below in my project. When I print all of these fixed
length string variables, one per line, they strings in questions do not
properly pad with 0s. strQuantity prints as " 4". Six spaces than

之外的六个空格


the

值。这是正确的。

但所有其他人最终都是长度只有6个字符的字符串对象
(strTotal除外)。字符串
对象的最左侧位置用一个太少的空格填充。这怎么可能?

昏暗的curTicket价格作为货币
昏暗的strTicketPrice As String * 7
Dim intQuantity as Integer
Dim strQuantity As String * 7
Dim curFee as Currency
Dim strFee As String * 7
Dim curSubtotal As Currency
Dim strSubtotal As String * 7
Dim curDiscount As Currency
Dim strDiscount As String * 7
Dim curTaxes as Currency
Dim strTaxes As String * 7
Dim curTotal as Currency
Dim strTotal As String * 7

intQuantity = 4
curTicketPrice = 150.00
curFee = 30.00
curSubtotal = 630.00
curDiscount = 60.00
curTaxes = 85.80
curTotal = 655.50

RSet strQuantity = Format (intQuantity,General Number)
RSet strTicketPrice =格式(curTicketPrice,fixed)
RSet strFee =格式(curFee,fixed)
RSet strSubtotal =格式(curSubtotal,fixed)
RSet strDiscount =格式(curDiscount,fixed)
RSet strTaxes =格式(curTaxes,fixed)
RSet strTotal =格式(curTotal,currency)


< Ade
-
Adrian Parker。被任命的牧师。 < ad *********** @ sympatico.ca>
想知道生活的目的吗?我很乐意和你分享......
value of intQuantity. This is correct.

But all the others end up being string objects of only 6 characters long
(with the exception of strTotal). The left most positions of the string
object are being padded with one too few spaces. How is this possible?

Dim curTicketPrice As Currency
Dim strTicketPrice As String * 7
Dim intQuantity As Integer
Dim strQuantity As String * 7
Dim curFee As Currency
Dim strFee As String * 7
Dim curSubtotal As Currency
Dim strSubtotal As String * 7
Dim curDiscount As Currency
Dim strDiscount As String * 7
Dim curTaxes As Currency
Dim strTaxes As String * 7
Dim curTotal As Currency
Dim strTotal As String * 7

intQuantity = 4
curTicketPrice = 150.00
curFee = 30.00
curSubtotal = 630.00
curDiscount = 60.00
curTaxes = 85.80
curTotal = 655.50

RSet strQuantity = Format(intQuantity, "General Number")
RSet strTicketPrice = Format(curTicketPrice, "fixed")
RSet strFee = Format(curFee, "fixed")
RSet strSubtotal = Format(curSubtotal, "fixed")
RSet strDiscount = Format(curDiscount, "fixed")
RSet strTaxes = Format(curTaxes, "fixed")
RSet strTotal = Format(curTotal, "currency")


<Ade
--
Adrian Parker. Ordained priest. <ad***********@sympatico.ca>
Want to know the purpose of life? I''d be happy to share it with you...




我不是确定你身在何处;但在这里,在我的系统上,所有

变量打印出7个字符长。换句话说,从我的角度来看,

您的代码没有任何问题。


您是否有特殊原因使用固定长度的字符串第一个

的地方?如果你需要用给定数量的字符打印结果,

你可以这样做


SevenPlacesRtJust =正确
I''m not sure what''s going on where you are; but here, on my system, all
variables print out 7 characters long. In other words, from my perspective,
there is nothing wrong with you code.

Is there a particular reason you are using fixed-length strings in the first
place? If you need to print out results with a give number of characters,
you could do this

SevenPlacesRtJust = Right


这篇关于RSet和固定长度字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆