By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,896 Members | 1,983 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,896 IT Pros & Developers. It's quick & easy.

RSet and Fixed Length Strings

P: n/a
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...
Jul 17 '05 #1
Share this Question
Share on Google+
26 Replies


P: n/a
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.. .
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...

Jul 17 '05 #2

P: n/a
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...
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.. .
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...


Jul 17 '05 #3

P: n/a
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$(" " & VariableSizeString, 7)

where VariableSizeString could be Format$(curTotal, "currency") as an
example; or, as another alternative, this

SevenPlacesRtJust = Format$(VariableSizeString, "@@@@@@@")

where, again, VariableSizeString could be Format$(curTotal, "currency") as
an example. Yes, that would be a Format$ function inside a Format$ function.
In the first statement above, that is 7 blank spaces between the quotes; in
the second statement, that is 7 "at" signs.

Rick - MVP

"Adrian Parker" <no@addy.com> wrote in message
news:oX*******************@news20.bellglobal.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...
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.. .
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...



Jul 17 '05 #4

P: n/a

"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message
news:SJ********************@comcast.com...
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
The decimal places of all numbers have to line up. All the lines have to be
shown in one label, and the right-most digit cannot be touching the right
edge of the label they are in.

I could possibly use your way though.

SevenPlacesRtJust = Right$(" " & VariableSizeString, 7)

where VariableSizeString could be Format$(curTotal, "currency") as an
example; or, as another alternative, this

SevenPlacesRtJust = Format$(VariableSizeString, "@@@@@@@")

where, again, VariableSizeString could be Format$(curTotal, "currency") as
an example. Yes, that would be a Format$ function inside a Format$ function. In the first statement above, that is 7 blank spaces between the quotes; in the second statement, that is 7 "at" signs.

Rick - MVP

"Adrian Parker" <no@addy.com> wrote in message
news:oX*******************@news20.bellglobal.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...
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.. .
> 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... >
>



Jul 17 '05 #5

P: n/a

"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message
news:SJ********************@comcast.com...
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$(" " & VariableSizeString, 7)
The content of the variables may vary. they can be from 1 - 7 charactes in
length. Your way requires that I know how wide (character length) the
string is.

I think.

?

where VariableSizeString could be Format$(curTotal, "currency") as an
example; or, as another alternative, this

SevenPlacesRtJust = Format$(VariableSizeString, "@@@@@@@")

where, again, VariableSizeString could be Format$(curTotal, "currency") as
an example. Yes, that would be a Format$ function inside a Format$ function. In the first statement above, that is 7 blank spaces between the quotes; in the second statement, that is 7 "at" signs.

Rick - MVP

"Adrian Parker" <no@addy.com> wrote in message
news:oX*******************@news20.bellglobal.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...
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.. .
> 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... >
>



Jul 17 '05 #6

P: n/a

"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message
news:SJ********************@comcast.com...
SevenPlacesRtJust = Format$(VariableSizeString, "@@@@@@@")


This doesn't seem to work at all my on VB 6.0 student edition. I looked
through the MSDN (perhaps I only saw VB.NET though, and it doesn't mention
the @@@@ type either.
Adrian
Jul 17 '05 #7

P: n/a

"Adrian Parker" <no@addy.com> wrote in message
news:Ic********************@news20.bellglobal.com. ..

"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message
news:SJ********************@comcast.com...
SevenPlacesRtJust = Format$(VariableSizeString, "@@@@@@@")


This doesn't seem to work at all my on VB 6.0 student edition. I looked
through the MSDN (perhaps I only saw VB.NET though, and it doesn't mention
the @@@@ type either.


Sorry, it does work. But the output is strange.

''''''''''''''''''''''''''''''''''' Code:
curTest = 1
curTest2 = 12
curTest3 = 1234
curTest4 = 1234567

MsgBox Format(curTest, "@@@@@@@") & vbNewLine & Format(curTest2,
"@@@@@@@") & vbNewLine _
& Format(curTest3, "@@@@@@@") & vbNewLine & Format(curTest4,
"@@@@@@@")
''''''''''''''''''''''''''''''''''' Output
1
12
1234
1234567

My output looks like a pyramid. Is this normal? I need all the numbers to
be aligned to the right.

Adrian
Jul 17 '05 #8

P: n/a

"Adrian Parker" <no@addy.com> wrote in message
news:nu********************@news20.bellglobal.com. ..

"Adrian Parker" <no@addy.com> wrote in message
news:Ic********************@news20.bellglobal.com. ..

"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message
news:SJ********************@comcast.com...
SevenPlacesRtJust = Format$(VariableSizeString, "@@@@@@@")


This doesn't seem to work at all my on VB 6.0 student edition. I looked
through the MSDN (perhaps I only saw VB.NET though, and it doesn't mention
the @@@@ type either.


Sorry, it does work. But the output is strange.

''''''''''''''''''''''''''''''''''' Code:
curTest = 1
curTest2 = 12
curTest3 = 1234
curTest4 = 1234567

MsgBox Format(curTest, "@@@@@@@") & vbNewLine & Format(curTest2,
"@@@@@@@") & vbNewLine _
& Format(curTest3, "@@@@@@@") & vbNewLine & Format(curTest4,
"@@@@@@@")
''''''''''''''''''''''''''''''''''' Output
1
12
1234
1234567

My output looks like a pyramid. Is this normal? I need all the numbers to
be aligned to the right.

Adrian


I think you need to change font. Unless you are in a mono-spaced font, the space
character will take up much less horizontal width than say the 3 character. You
won't get right justification just by padding with spaces. In the above example,
the 1 at the top is the sixth character, as is the 4 in the third row.

You may also get a trailing space with currency variables, because the standard
currency format shows negative numbers in parentheses, and puts spaces around
positive numbers.
Jul 17 '05 #9

P: n/a
You've raised several questions which I've combined into this one message.
See my inline comments...
The decimal places of all numbers have to line up. All the
lines have to be shown in one label, and the right-most digit
cannot be touching the right edge of the label they are in.
You didn't mention this originally. Are you looking for trailing zeroes in
order "fill out" the right side of each number? Or are you looking to have a
"ragged" right side?

The content of the variables may vary. they can be from
1 - 7 charactes in length. Your way requires that I know
how wide (character length) the string is.
You have to know something about the width of the numbers or you won't be
able to tell how to place them so their decimal points line up, right?

SevenPlacesRtJust = Format$(VariableSizeString, "@@@@@@@")


This doesn't seem to work at all my on VB 6.0 student edition.
I looked through the MSDN (perhaps I only saw VB.NET
though, and it doesn't mention the @@@@ type either.


Sorry, it does work. But the output is strange.

''''''''''''''''''''''''''''''''''' Output
1
12
1234
1234567

My output looks like a pyramid. Is this normal? I need all the
numbers to be aligned to the right.


This will require you to use a fixed-width font instead of a
proportionally-spaced font. Try using Courier New.
Rick - MVP

Jul 17 '05 #10

P: n/a

"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message
news:NY********************@comcast.com...
You've raised several questions which I've combined into this one message.
See my inline comments...
The decimal places of all numbers have to line up. All the
lines have to be shown in one label, and the right-most digit
cannot be touching the right edge of the label they are in.
You didn't mention this originally. Are you looking for trailing zeroes in
order "fill out" the right side of each number? Or are you looking to have

a "ragged" right side?

The content of the variables may vary. they can be from
1 - 7 charactes in length. Your way requires that I know
how wide (character length) the string is.


You have to know something about the width of the numbers or you won't be
able to tell how to place them so their decimal points line up, right?


Hence I make a fixed length string, larger than they can be, and right align
it.

All numbers will have two decimal places. The first one doesn't, but don't
worry about it's alignment.

> SevenPlacesRtJust = Format$(VariableSizeString, "@@@@@@@")

This doesn't seem to work at all my on VB 6.0 student edition.
I looked through the MSDN (perhaps I only saw VB.NET
though, and it doesn't mention the @@@@ type either.


Sorry, it does work. But the output is strange.

''''''''''''''''''''''''''''''''''' Output
1
12
1234
1234567

My output looks like a pyramid. Is this normal? I need all the
numbers to be aligned to the right.


This will require you to use a fixed-width font instead of a
proportionally-spaced font. Try using Courier New.


When I try with fixed with the first record is fine. All the other records
(mostly Fixed format, one is currency), fall one short.

If the first one is 6 blank spaces then a 1, as it should be. If the second
number is 1.00 (4 characters), there will be 2 blank spaces before it.
Which is one short of making it 7.

If I delete the first printed one, then the new first line has the proper
amount of spaces, but the one following doesn't.
' Using Courier new font on lblOutput3

lblOutput3.Caption = Format(intQuantity, "@@@@@@@") & vbNewLine _
& Format(Format(curTicketPrice, "fixed"), "@@@@@@@@") & vbNewLine _
& Format(Format(curFee, "fixed"), "@@@@@@@@") & vbNewLine _
& Format(Format(curSubtotal, "fixed"), "@@@@@@@@") & vbNewLine &
vbNewLine

If curDiscount <> " 0.00" Then
lblOutput3.Caption = lblOutput3.Caption _
& Format(Format(curDiscount, "fixed"), "@@@@@@@") & vbNewLine &
vbNewLine
End If

lblOutput3.Caption = lblOutput3.Caption _
& Format(Format(curTaxes, "fixed"), "@@@@@@@@") & vbNewLine _
& Format(Format(curTotal, "currency"), "@@@@@@@")
Adrian
Jul 17 '05 #11

P: n/a
On Fri, 31 Oct 2003 13:00:05 -0500, "Adrian Parker" <no@addy.com>
wrote:
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.


Unless I am totally mistaken, all this thread is missing the point

- this is a printing problem

CurrentX and TextWidth() will sort out the mess
Jul 17 '05 #12

P: n/a

"J French" <er*****@nowhere.com> wrote in message
news:3f****************@news.btclick.com...
On Fri, 31 Oct 2003 13:00:05 -0500, "Adrian Parker" <no@addy.com>
wrote:
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 thevalue of intQuantity. This is correct.


Unless I am totally mistaken, all this thread is missing the point

- this is a printing problem

CurrentX and TextWidth() will sort out the mess


You're totally missing the point <smiles>

The letters are being placed into a label's caption property.

Using this all the numbers line up (please notice that the first field is
defined as 7 characters in length, all the others have to be defined 8 in
length):

lblOutput3.Caption = Format(intQuantity, "@@@@@@@") & vbNewLine _
& Format(Format(curTicketPrice, "fixed"), "@@@@@@@@") & vbNewLine _
& Format(Format(curFee, "fixed"), "@@@@@@@@") & vbNewLine _
& Format(Format(curSubtotal, "fixed"), "@@@@@@@@") & vbNewLine &
vbNewLine

If curDiscount <> " 0.00" Then
lblOutput3.Caption = lblOutput3.Caption _
& Format(Format(curDiscount, "fixed"), "@@@@@@@") & vbNewLine &
vbNewLine
End If

lblOutput3.Caption = lblOutput3.Caption _
& Format(Format(curTaxes, "fixed"), "@@@@@@@@") & vbNewLine _
& Format(Format(curTotal, "currency"), "@@@@@@@")

Why does the first one have to be set longer than the others?

Adrian
Jul 17 '05 #13

P: n/a
I'm not sure from your post whether there is a question remaining or not.
Did the Format function with Courier New work correctly or not?

Rick - MVP

"Adrian Parker" <no@addy.com> wrote in message
news:xo*******************@news20.bellglobal.com.. .

"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message
news:NY********************@comcast.com...
You've raised several questions which I've combined into this one message.
See my inline comments...
The decimal places of all numbers have to line up. All the
lines have to be shown in one label, and the right-most digit
cannot be touching the right edge of the label they are in.
You didn't mention this originally. Are you looking for trailing zeroes in order "fill out" the right side of each number? Or are you looking to have a
"ragged" right side?

The content of the variables may vary. they can be from
1 - 7 charactes in length. Your way requires that I know
how wide (character length) the string is.
You have to know something about the width of the numbers or you won't

be able to tell how to place them so their decimal points line up, right?


Hence I make a fixed length string, larger than they can be, and right

align it.

All numbers will have two decimal places. The first one doesn't, but don't worry about it's alignment.

> SevenPlacesRtJust = Format$(VariableSizeString, "@@@@@@@")
>
> This doesn't seem to work at all my on VB 6.0 student edition.
> I looked through the MSDN (perhaps I only saw VB.NET
> though, and it doesn't mention the @@@@ type either.

Sorry, it does work. But the output is strange.
''''''''''''''''''''''''''''''''''' Output
1
12
1234
1234567

My output looks like a pyramid. Is this normal? I need all the
numbers to be aligned to the right.


This will require you to use a fixed-width font instead of a
proportionally-spaced font. Try using Courier New.


When I try with fixed with the first record is fine. All the other

records (mostly Fixed format, one is currency), fall one short.

If the first one is 6 blank spaces then a 1, as it should be. If the second number is 1.00 (4 characters), there will be 2 blank spaces before it.
Which is one short of making it 7.

If I delete the first printed one, then the new first line has the proper
amount of spaces, but the one following doesn't.
' Using Courier new font on lblOutput3

lblOutput3.Caption = Format(intQuantity, "@@@@@@@") & vbNewLine _
& Format(Format(curTicketPrice, "fixed"), "@@@@@@@@") & vbNewLine _ & Format(Format(curFee, "fixed"), "@@@@@@@@") & vbNewLine _
& Format(Format(curSubtotal, "fixed"), "@@@@@@@@") & vbNewLine &
vbNewLine

If curDiscount <> " 0.00" Then
lblOutput3.Caption = lblOutput3.Caption _
& Format(Format(curDiscount, "fixed"), "@@@@@@@") & vbNewLine & vbNewLine
End If

lblOutput3.Caption = lblOutput3.Caption _
& Format(Format(curTaxes, "fixed"), "@@@@@@@@") & vbNewLine _
& Format(Format(curTotal, "currency"), "@@@@@@@")
Adrian

Jul 17 '05 #14

P: n/a

"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message
news:Br********************@comcast.com...
I'm not sure from your post whether there is a question remaining or not.
Did the Format function with Courier New work correctly or not?

No. The do not right align, so that the decimals line up.

The formatted variable looks appropriate. 7 characters long, padded with
spaces on the left. However when they are displayed in the label, they
appear as 6 characters long (it might seem a space is appended to the end of
the string).

In order to get all the numbers to line up, the first line has to be
formatted to be one character long than the rest of the values. This works
fine unless the numbers use become very small (less than 20 or so), or very
large (over 10,000).

It seems as though the formatted numbers are having a single space padded to
the right side (along with spaces to the left of the number).


' This method and the RSet logic give the exact same output. Both seem
wrong.

lblOutput3.Caption = Format(intQuantity, "@@@@@@@") & vbNewLine _
& Format(Format(curTicketPrice, "fixed"), "@@@@@@@") & vbNewLine _
& Format(Format(curFee, "fixed"), "@@@@@@@") & vbNewLine _
& Format(Format(curSubtotal, "fixed"), "@@@@@@@") & vbNewLine &
vbNewLine

If curDiscount <> " 0.00" Then
lblOutput3.Caption = lblOutput3.Caption _
& Format(Format(curDiscount, "fixed"), "@@@@@@@") & vbNewLine &
vbNewLine
End If

lblOutput3.Caption = lblOutput3.Caption _
& Format(Format(curTaxes, "fixed"), "@@@@@@@") & vbNewLine _
& Format(Format(curTotal, "currency"), "@@@@@@@")
Where:
intQuantity = 1
curTicketPrice = 150
curFee = 30
curSubtotal = 630
curDiscount = 60
curTaxes = 85.5
curTotal = 655.5


Rick - MVP

"Adrian Parker" <no@addy.com> wrote in message
news:xo*******************@news20.bellglobal.com.. .

"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message
news:NY********************@comcast.com...
You've raised several questions which I've combined into this one message. See my inline comments...

> The decimal places of all numbers have to line up. All the
> lines have to be shown in one label, and the right-most digit
> cannot be touching the right edge of the label they are in.

You didn't mention this originally. Are you looking for trailing
zeroes
in order "fill out" the right side of each number? Or are you looking to have
a
"ragged" right side?
> The content of the variables may vary. they can be from
> 1 - 7 charactes in length. Your way requires that I know
> how wide (character length) the string is.

You have to know something about the width of the numbers or you won't be able to tell how to place them so their decimal points line up, right?
Hence I make a fixed length string, larger than they can be, and right

align
it.

All numbers will have two decimal places. The first one doesn't, but

don't
worry about it's alignment.

> > > SevenPlacesRtJust = Format$(VariableSizeString, "@@@@@@@")
> >
> > This doesn't seem to work at all my on VB 6.0 student edition.
> > I looked through the MSDN (perhaps I only saw VB.NET
> > though, and it doesn't mention the @@@@ type either.
>
> Sorry, it does work. But the output is strange.
>

> ''''''''''''''''''''''''''''''''''' Output
> 1
> 12
> 1234
> 1234567
>
> My output looks like a pyramid. Is this normal? I need all the
> numbers to be aligned to the right.

This will require you to use a fixed-width font instead of a
proportionally-spaced font. Try using Courier New.


When I try with fixed with the first record is fine. All the other

records
(mostly Fixed format, one is currency), fall one short.

If the first one is 6 blank spaces then a 1, as it should be. If the

second
number is 1.00 (4 characters), there will be 2 blank spaces before it.
Which is one short of making it 7.

If I delete the first printed one, then the new first line has the

proper amount of spaces, but the one following doesn't.
' Using Courier new font on lblOutput3

lblOutput3.Caption = Format(intQuantity, "@@@@@@@") & vbNewLine _
& Format(Format(curTicketPrice, "fixed"), "@@@@@@@@") &

vbNewLine _
& Format(Format(curFee, "fixed"), "@@@@@@@@") & vbNewLine _
& Format(Format(curSubtotal, "fixed"), "@@@@@@@@") & vbNewLine &
vbNewLine

If curDiscount <> " 0.00" Then
lblOutput3.Caption = lblOutput3.Caption _
& Format(Format(curDiscount, "fixed"), "@@@@@@@") &
vbNewLine &
vbNewLine
End If

lblOutput3.Caption = lblOutput3.Caption _
& Format(Format(curTaxes, "fixed"), "@@@@@@@@") & vbNewLine _
& Format(Format(curTotal, "currency"), "@@@@@@@")
Adrian


Jul 17 '05 #15

P: n/a
On Sat, 1 Nov 2003 09:27:01 -0500, "Adrian Parker" <no@addy.com>
wrote:

<snip>
Unless I am totally mistaken, all this thread is missing the point

- this is a printing problem

CurrentX and TextWidth() will sort out the mess


You're totally missing the point <smiles>

The letters are being placed into a label's caption property.

<snip>

Oh my God !

Why are you using a f****** Label ?

Use a Picturebox - otherwise ... you are condemned to dubious control
of your presentation
Jul 17 '05 #16

P: n/a
> > I'm not sure from your post whether there is a question remaining or
not.
Did the Format function with Courier New work correctly or not?

No. The do not right align, so that the decimals line up.

The formatted variable looks appropriate. 7 characters long, padded with
spaces on the left. However when they are displayed in the label, they
appear as 6 characters long (it might seem a space is appended to the end

of the string).

In order to get all the numbers to line up, the first line has to be
formatted to be one character long than the rest of the values. This works fine unless the numbers use become very small (less than 20 or so), or very large (over 10,000).

It seems as though the formatted numbers are having a single space padded to the right side (along with spaces to the left of the number).


' This method and the RSet logic give the exact same output. Both seem wrong.

lblOutput3.Caption = Format(intQuantity, "@@@@@@@") & vbNewLine _
& Format(Format(curTicketPrice, "fixed"), "@@@@@@@") & vbNewLine _
& Format(Format(curFee, "fixed"), "@@@@@@@") & vbNewLine _
& Format(Format(curSubtotal, "fixed"), "@@@@@@@") & vbNewLine &
vbNewLine

If curDiscount <> " 0.00" Then
lblOutput3.Caption = lblOutput3.Caption _
& Format(Format(curDiscount, "fixed"), "@@@@@@@") & vbNewLine & vbNewLine
End If

lblOutput3.Caption = lblOutput3.Caption _
& Format(Format(curTaxes, "fixed"), "@@@@@@@") & vbNewLine _
& Format(Format(curTotal, "currency"), "@@@@@@@")
Where:
intQuantity = 1
curTicketPrice = 150
curFee = 30
curSubtotal = 630
curDiscount = 60
curTaxes = 85.5
curTotal = 655.5


I'm not sure why, but you seem to be right about the Label removing one of
the formatting "blank spaces"... using eight @ signs only prints 7 positions
in the Label. However, I don't have any problem aligning the numbers (once
two of Format statements have their seven @ signs increased to eight of them
like the rest of the statement). The attached BMP file shows what I get on
my screen (using Courier New for the font).

Rick - MVP
Jul 17 '05 #17

P: n/a

"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message
news:DZ********************@comcast.com...
I'm not sure from your post whether there is a question remaining or not. Did the Format function with Courier New work correctly or not?

No. The do not right align, so that the decimals line up.

The formatted variable looks appropriate. 7 characters long, padded with spaces on the left. However when they are displayed in the label, they
appear as 6 characters long (it might seem a space is appended to the end of
the string).

In order to get all the numbers to line up, the first line has to be
formatted to be one character long than the rest of the values. This works
fine unless the numbers use become very small (less than 20 or so), or

very
large (over 10,000).

It seems as though the formatted numbers are having a single space

padded to
the right side (along with spaces to the left of the number).


' This method and the RSet logic give the exact same output. Both seem
wrong.

lblOutput3.Caption = Format(intQuantity, "@@@@@@@") & vbNewLine _
& Format(Format(curTicketPrice, "fixed"), "@@@@@@@") & vbNewLine

_ & Format(Format(curFee, "fixed"), "@@@@@@@") & vbNewLine _
& Format(Format(curSubtotal, "fixed"), "@@@@@@@") & vbNewLine &
vbNewLine

If curDiscount <> " 0.00" Then
lblOutput3.Caption = lblOutput3.Caption _
& Format(Format(curDiscount, "fixed"), "@@@@@@@") &

vbNewLine &
vbNewLine
End If

lblOutput3.Caption = lblOutput3.Caption _
& Format(Format(curTaxes, "fixed"), "@@@@@@@") & vbNewLine _
& Format(Format(curTotal, "currency"), "@@@@@@@")
Where:
intQuantity = 1
curTicketPrice = 150
curFee = 30
curSubtotal = 630
curDiscount = 60
curTaxes = 85.5
curTotal = 655.5
I'm not sure why, but you seem to be right about the Label removing one of
the formatting "blank spaces"... using eight @ signs only prints 7

positions in the Label. However, I don't have any problem aligning the numbers (once
two of Format statements have their seven @ signs increased to eight of them like the rest of the statement). The attached BMP file shows what I get on
my screen (using Courier New for the font).


But if the input used increases or decreases dramatically, the numbers no
longer line up.
Adrian
Jul 17 '05 #18

P: n/a

"J French" <er*****@nowhere.com> wrote in message
news:3f****************@news.btclick.com...
On Sat, 1 Nov 2003 09:27:01 -0500, "Adrian Parker" <no@addy.com>
wrote:

<snip>
Unless I am totally mistaken, all this thread is missing the point

- this is a printing problem

CurrentX and TextWidth() will sort out the mess


You're totally missing the point <smiles>

The letters are being placed into a label's caption property.

<snip>

Oh my God !

Why are you using a f****** Label ?

Use a Picturebox - otherwise ... you are condemned to dubious control
of your presentation


It's for school. We have to use a Label. It's part of the assignment
requirements.

Can you add anything to the discussion?
Adrian
Jul 17 '05 #19

P: n/a
> > > > I'm not sure from your post whether there is a question remaining or
not.
> Did the Format function with Courier New work correctly or not?
No. The do not right align, so that the decimals line up.

The formatted variable looks appropriate. 7 characters long, padded with spaces on the left. However when they are displayed in the label, they appear as 6 characters long (it might seem a space is appended to the end
of
the string).

In order to get all the numbers to line up, the first line has to be
formatted to be one character long than the rest of the values. This works
fine unless the numbers use become very small (less than 20 or so), or

very
large (over 10,000).

It seems as though the formatted numbers are having a single space padded
to
the right side (along with spaces to the left of the number).


' This method and the RSet logic give the exact same output. Both

seem
wrong.

lblOutput3.Caption = Format(intQuantity, "@@@@@@@") & vbNewLine _
& Format(Format(curTicketPrice, "fixed"), "@@@@@@@") & vbNewLine _ & Format(Format(curFee, "fixed"), "@@@@@@@") & vbNewLine _
& Format(Format(curSubtotal, "fixed"), "@@@@@@@") & vbNewLine

& vbNewLine

If curDiscount <> " 0.00" Then
lblOutput3.Caption = lblOutput3.Caption _
& Format(Format(curDiscount, "fixed"), "@@@@@@@") &

vbNewLine
&
vbNewLine
End If

lblOutput3.Caption = lblOutput3.Caption _
& Format(Format(curTaxes, "fixed"), "@@@@@@@") & vbNewLine _
& Format(Format(curTotal, "currency"), "@@@@@@@")
Where:
intQuantity = 1
curTicketPrice = 150
curFee = 30
curSubtotal = 630
curDiscount = 60
curTaxes = 85.5
curTotal = 655.5


I'm not sure why, but you seem to be right about the Label removing one

of the formatting "blank spaces"... using eight @ signs only prints 7

positions
in the Label. However, I don't have any problem aligning the numbers (once two of Format statements have their seven @ signs increased to eight of

them
like the rest of the statement). The attached BMP file shows what I get on my screen (using Courier New for the font).


But if the input used increases or decreases dramatically, the numbers no
longer line up.


As long as you use a correctly written Format statements, separated by
newline character sequences, they should align with no trouble (at least
until you run out of room in the Label).

Rick - MVP
Jul 17 '05 #20

P: n/a

"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message
news:LK********************@comcast.com...
> > I'm not sure from your post whether there is a question remaining or not.
> > Did the Format function with Courier New work correctly or not?
>
>
> No. The do not right align, so that the decimals line up.
>
> The formatted variable looks appropriate. 7 characters long, padded with
> spaces on the left. However when they are displayed in the label, they > appear as 6 characters long (it might seem a space is appended to the
end
of
> the string).
>
> In order to get all the numbers to line up, the first line has to be
> formatted to be one character long than the rest of the values.
This works
> fine unless the numbers use become very small (less than 20 or so), or very
> large (over 10,000).
>
> It seems as though the formatted numbers are having a single space

padded
to
> the right side (along with spaces to the left of the number).
>
>
>
>
> ' This method and the RSet logic give the exact same output. Both seem
> wrong.
>
> lblOutput3.Caption = Format(intQuantity, "@@@@@@@") & vbNewLine _ > & Format(Format(curTicketPrice, "fixed"), "@@@@@@@") & vbNewLine
_
> & Format(Format(curFee, "fixed"), "@@@@@@@") & vbNewLine _
> & Format(Format(curSubtotal, "fixed"), "@@@@@@@") &

vbNewLine & > vbNewLine
>
> If curDiscount <> " 0.00" Then
> lblOutput3.Caption = lblOutput3.Caption _
> & Format(Format(curDiscount, "fixed"), "@@@@@@@") & vbNewLine
&
> vbNewLine
> End If
>
> lblOutput3.Caption = lblOutput3.Caption _
> & Format(Format(curTaxes, "fixed"), "@@@@@@@") & vbNewLine _
> & Format(Format(curTotal, "currency"), "@@@@@@@")
>
>
> Where:
> intQuantity = 1
> curTicketPrice = 150
> curFee = 30
> curSubtotal = 630
> curDiscount = 60
> curTaxes = 85.5
> curTotal = 655.5

I'm not sure why, but you seem to be right about the Label removing
one of the formatting "blank spaces"... using eight @ signs only prints 7 positions
in the Label. However, I don't have any problem aligning the numbers (once two of Format statements have their seven @ signs increased to eight
of them
like the rest of the statement). The attached BMP file shows what I
get on my screen (using Courier New for the font).


But if the input used increases or decreases dramatically, the numbers

no longer line up.


As long as you use a correctly written Format statements, separated by
newline character sequences, they should align with no trouble (at least
until you run out of room in the Label).


Look at my code above.

Each field is set to 7 characters in length. The printed to screen, padded
with spaces on the left.

Yet for some reason some of the numbers are appearing with a single space on
their right. The variable holds the proper value, when you use it in the
label's caption, an extra space is added at the end of all but one of the
lines.
Adrian
Jul 17 '05 #21

P: n/a

"Adrian Parker" <no@addy.com> wrote in message
news:1y****************@news20.bellglobal.com...

"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message
news:LK********************@comcast.com...
> > > I'm not sure from your post whether there is a question remaining or > not.
> > > Did the Format function with Courier New work correctly or not?
> >
> >
> > No. The do not right align, so that the decimals line up.
> >
> > The formatted variable looks appropriate. 7 characters long, padded
with
> > spaces on the left. However when they are displayed in the label,

they
> > appear as 6 characters long (it might seem a space is appended to the end
> of
> > the string).
> >
> > In order to get all the numbers to line up, the first line has to be
> > formatted to be one character long than the rest of the values. This > works
> > fine unless the numbers use become very small (less than 20 or so), or > very
> > large (over 10,000).
> >
> > It seems as though the formatted numbers are having a single space
padded
> to
> > the right side (along with spaces to the left of the number).
> >
> >
> >
> >
> > ' This method and the RSet logic give the exact same output. Both > seem
> > wrong.
> >
> > lblOutput3.Caption = Format(intQuantity, "@@@@@@@") & vbNewLine _ > > & Format(Format(curTicketPrice, "fixed"), "@@@@@@@") &

vbNewLine
_
> > & Format(Format(curFee, "fixed"), "@@@@@@@") & vbNewLine _
> > & Format(Format(curSubtotal, "fixed"), "@@@@@@@") & vbNewLine
&
> > vbNewLine
> >
> > If curDiscount <> " 0.00" Then
> > lblOutput3.Caption = lblOutput3.Caption _
> > & Format(Format(curDiscount, "fixed"), "@@@@@@@") &
vbNewLine
> &
> > vbNewLine
> > End If
> >
> > lblOutput3.Caption = lblOutput3.Caption _
> > & Format(Format(curTaxes, "fixed"), "@@@@@@@") & vbNewLine _
> > & Format(Format(curTotal, "currency"), "@@@@@@@")
> >
> >
> > Where:
> > intQuantity = 1
> > curTicketPrice = 150
> > curFee = 30
> > curSubtotal = 630
> > curDiscount = 60
> > curTaxes = 85.5
> > curTotal = 655.5
>
> I'm not sure why, but you seem to be right about the Label removing

one
of
> the formatting "blank spaces"... using eight @ signs only prints 7
positions
> in the Label. However, I don't have any problem aligning the numbers

(once
> two of Format statements have their seven @ signs increased to eight

of them
> like the rest of the statement). The attached BMP file shows what I get
on
> my screen (using Courier New for the font).

But if the input used increases or decreases dramatically, the numbers

no longer line up.


As long as you use a correctly written Format statements, separated by
newline character sequences, they should align with no trouble (at least
until you run out of room in the Label).


Look at my code above.

Each field is set to 7 characters in length. The printed to screen, padded
with spaces on the left.

Yet for some reason some of the numbers are appearing with a single space on
their right. The variable holds the proper value, when you use it in the
label's caption, an extra space is added at the end of all but one of the
lines.
Adrian


I still think this is the reason (from my earlier post):

You may also get a trailing space with currency variables, because the standard
currency format shows negative numbers in parentheses, and puts spaces around
positive numbers.
Jul 17 '05 #22

P: n/a

"Steve Gerrard" <no*************@comcast.net> wrote in message
news:Ke********************@comcast.com...

"Adrian Parker" <no@addy.com> wrote in message
news:1y****************@news20.bellglobal.com...

"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message
news:LK********************@comcast.com...
> > > > I'm not sure from your post whether there is a question remaining
or
> > not.
> > > > Did the Format function with Courier New work correctly or
not? > > >
> > >
> > > No. The do not right align, so that the decimals line up.
> > >
> > > The formatted variable looks appropriate. 7 characters long, padded > with
> > > spaces on the left. However when they are displayed in the label, they
> > > appear as 6 characters long (it might seem a space is appended to the
> end
> > of
> > > the string).
> > >
> > > In order to get all the numbers to line up, the first line has
to be > > > formatted to be one character long than the rest of the values. This
> > works
> > > fine unless the numbers use become very small (less than 20 or so), or
> > very
> > > large (over 10,000).
> > >
> > > It seems as though the formatted numbers are having a single
space > padded
> > to
> > > the right side (along with spaces to the left of the number).
> > >
> > >
> > >
> > >
> > > ' This method and the RSet logic give the exact same output.

Both
> > seem
> > > wrong.
> > >
> > > lblOutput3.Caption = Format(intQuantity, "@@@@@@@") & vbNewLine _
> > > & Format(Format(curTicketPrice, "fixed"), "@@@@@@@") &
vbNewLine
> _
> > > & Format(Format(curFee, "fixed"), "@@@@@@@") & vbNewLine
_ > > > & Format(Format(curSubtotal, "fixed"), "@@@@@@@") &

vbNewLine
&
> > > vbNewLine
> > >
> > > If curDiscount <> " 0.00" Then
> > > lblOutput3.Caption = lblOutput3.Caption _
> > > & Format(Format(curDiscount, "fixed"), "@@@@@@@") &
> vbNewLine
> > &
> > > vbNewLine
> > > End If
> > >
> > > lblOutput3.Caption = lblOutput3.Caption _
> > > & Format(Format(curTaxes, "fixed"), "@@@@@@@") & vbNewLine _ > > > & Format(Format(curTotal, "currency"), "@@@@@@@")
> > >
> > >
> > > Where:
> > > intQuantity = 1
> > > curTicketPrice = 150
> > > curFee = 30
> > > curSubtotal = 630
> > > curDiscount = 60
> > > curTaxes = 85.5
> > > curTotal = 655.5
> >
> > I'm not sure why, but you seem to be right about the Label removing one
of
> > the formatting "blank spaces"... using eight @ signs only prints 7
> positions
> > in the Label. However, I don't have any problem aligning the
numbers (once
> > two of Format statements have their seven @ signs increased to eight of
> them
> > like the rest of the statement). The attached BMP file shows what
I get
on
> > my screen (using Courier New for the font).
>
> But if the input used increases or decreases dramatically, the
numbers no
> longer line up.

As long as you use a correctly written Format statements, separated by
newline character sequences, they should align with no trouble (at
least until you run out of room in the Label).


Look at my code above.

Each field is set to 7 characters in length. The printed to screen,

padded with spaces on the left.

Yet for some reason some of the numbers are appearing with a single space on their right. The variable holds the proper value, when you use it in the label's caption, an extra space is added at the end of all but one of the lines.
Adrian


I still think this is the reason (from my earlier post):

You may also get a trailing space with currency variables, because the

standard currency format shows negative numbers in parentheses, and puts spaces around positive numbers.


What is the fix?

I tried rtrim to no avail. I have had other assignment where the numbers
lined up fine.

I checked the MSDN, positive numbers do not return a blank character as a
placeholder for the parentheses (see the MSDN on Formatting).

Adrian
Jul 17 '05 #23

P: n/a

"Steve Gerrard" <no*************@comcast.net> wrote in message
news:Ke********************@comcast.com...

"Adrian Parker" <no@addy.com> wrote in message
news:1y****************@news20.bellglobal.com...

"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message
news:LK********************@comcast.com...
> > > > I'm not sure from your post whether there is a question remaining
or
> > not.
> > > > Did the Format function with Courier New work correctly or
not? > > >
> > >
> > > No. The do not right align, so that the decimals line up.
> > >
> > > The formatted variable looks appropriate. 7 characters long, padded > with
> > > spaces on the left. However when they are displayed in the label, they
> > > appear as 6 characters long (it might seem a space is appended to the
> end
> > of
> > > the string).
> > >
> > > In order to get all the numbers to line up, the first line has
to be > > > formatted to be one character long than the rest of the values. This
> > works
> > > fine unless the numbers use become very small (less than 20 or so), or
> > very
> > > large (over 10,000).
> > >
> > > It seems as though the formatted numbers are having a single
space > padded
> > to
> > > the right side (along with spaces to the left of the number).
> > >
> > >
> > >
> > >
> > > ' This method and the RSet logic give the exact same output.

Both
> > seem
> > > wrong.
> > >
> > > lblOutput3.Caption = Format(intQuantity, "@@@@@@@") & vbNewLine _
> > > & Format(Format(curTicketPrice, "fixed"), "@@@@@@@") &
vbNewLine
> _
> > > & Format(Format(curFee, "fixed"), "@@@@@@@") & vbNewLine
_ > > > & Format(Format(curSubtotal, "fixed"), "@@@@@@@") &

vbNewLine
&
> > > vbNewLine
> > >
> > > If curDiscount <> " 0.00" Then
> > > lblOutput3.Caption = lblOutput3.Caption _
> > > & Format(Format(curDiscount, "fixed"), "@@@@@@@") &
> vbNewLine
> > &
> > > vbNewLine
> > > End If
> > >
> > > lblOutput3.Caption = lblOutput3.Caption _
> > > & Format(Format(curTaxes, "fixed"), "@@@@@@@") & vbNewLine _ > > > & Format(Format(curTotal, "currency"), "@@@@@@@")
> > >
> > >
> > > Where:
> > > intQuantity = 1
> > > curTicketPrice = 150
> > > curFee = 30
> > > curSubtotal = 630
> > > curDiscount = 60
> > > curTaxes = 85.5
> > > curTotal = 655.5
> >
> > I'm not sure why, but you seem to be right about the Label removing one
of
> > the formatting "blank spaces"... using eight @ signs only prints 7
> positions
> > in the Label. However, I don't have any problem aligning the
numbers (once
> > two of Format statements have their seven @ signs increased to eight of
> them
> > like the rest of the statement). The attached BMP file shows what
I get
on
> > my screen (using Courier New for the font).
>
> But if the input used increases or decreases dramatically, the
numbers no
> longer line up.

As long as you use a correctly written Format statements, separated by
newline character sequences, they should align with no trouble (at
least until you run out of room in the Label).


Look at my code above.

Each field is set to 7 characters in length. The printed to screen,

padded with spaces on the left.

Yet for some reason some of the numbers are appearing with a single space on their right. The variable holds the proper value, when you use it in the label's caption, an extra space is added at the end of all but one of the lines.
Adrian


I still think this is the reason (from my earlier post):

You may also get a trailing space with currency variables, because the

standard currency format shows negative numbers in parentheses, and puts spaces around positive numbers.


Also, the General Number format is not getting the trailing space, but the
"Fixed" formatting also is.

It's not just the currency. In fact the currency one is aligned properly.

Adrian
Jul 17 '05 #24

P: n/a

"Adrian Parker" <no@addy.com> wrote in message
news:wh****************@news20.bellglobal.com...

"Steve Gerrard" <no*************@comcast.net> wrote in message
news:Ke********************@comcast.com...

"Adrian Parker" <no@addy.com> wrote in message
news:1y****************@news20.bellglobal.com...

"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message
news:LK********************@comcast.com...
> > > > > I'm not sure from your post whether there is a question remaining or
> > > not.
> > > > > Did the Format function with Courier New work correctly or not? > > > >
> > > >
> > > > No. The do not right align, so that the decimals line up.
> > > >
> > > > The formatted variable looks appropriate. 7 characters long, padded > > with
> > > > spaces on the left. However when they are displayed in the label, > they
> > > > appear as 6 characters long (it might seem a space is appended to the
> > end
> > > of
> > > > the string).
> > > >
> > > > In order to get all the numbers to line up, the first line has to be > > > > formatted to be one character long than the rest of the values.
This
> > > works
> > > > fine unless the numbers use become very small (less than 20 or so), or
> > > very
> > > > large (over 10,000).
> > > >
> > > > It seems as though the formatted numbers are having a single space > > padded
> > > to
> > > > the right side (along with spaces to the left of the number).
> > > >
> > > >
> > > >
> > > >
> > > > ' This method and the RSet logic give the exact same output.
Both
> > > seem
> > > > wrong.
> > > >
> > > > lblOutput3.Caption = Format(intQuantity, "@@@@@@@") & vbNewLine _
> > > > & Format(Format(curTicketPrice, "fixed"), "@@@@@@@") &
> vbNewLine
> > _
> > > > & Format(Format(curFee, "fixed"), "@@@@@@@") & vbNewLine _ > > > > & Format(Format(curSubtotal, "fixed"), "@@@@@@@") &
vbNewLine
> &
> > > > vbNewLine
> > > >
> > > > If curDiscount <> " 0.00" Then
> > > > lblOutput3.Caption = lblOutput3.Caption _
> > > > & Format(Format(curDiscount, "fixed"), "@@@@@@@") &
> > vbNewLine
> > > &
> > > > vbNewLine
> > > > End If
> > > >
> > > > lblOutput3.Caption = lblOutput3.Caption _
> > > > & Format(Format(curTaxes, "fixed"), "@@@@@@@") & vbNewLine _ > > > > & Format(Format(curTotal, "currency"), "@@@@@@@")
> > > >
> > > >
> > > > Where:
> > > > intQuantity = 1
> > > > curTicketPrice = 150
> > > > curFee = 30
> > > > curSubtotal = 630
> > > > curDiscount = 60
> > > > curTaxes = 85.5
> > > > curTotal = 655.5
> > >
> > > I'm not sure why, but you seem to be right about the Label removing one
> of
> > > the formatting "blank spaces"... using eight @ signs only prints 7
> > positions
> > > in the Label. However, I don't have any problem aligning the numbers > (once
> > > two of Format statements have their seven @ signs increased to eight of
> > them
> > > like the rest of the statement). The attached BMP file shows what I get
> on
> > > my screen (using Courier New for the font).
> >
> > But if the input used increases or decreases dramatically, the numbers no
> > longer line up.
>
> As long as you use a correctly written Format statements, separated by
> newline character sequences, they should align with no trouble (at least > until you run out of room in the Label).

Look at my code above.

Each field is set to 7 characters in length. The printed to screen, padded with spaces on the left.

Yet for some reason some of the numbers are appearing with a single space on their right. The variable holds the proper value, when you use it in the label's caption, an extra space is added at the end of all but one of the lines.
Adrian


I still think this is the reason (from my earlier post):

You may also get a trailing space with currency variables, because the

standard
currency format shows negative numbers in parentheses, and puts spaces

around
positive numbers.


Also, the General Number format is not getting the trailing space, but the
"Fixed" formatting also is.

It's not just the currency. In fact the currency one is aligned properly.

Adrian


You're right. Sorry about the red herring.

I tried your code and got the same odd result, and was able to show that it is
an odd property of the label.

If you add a textbox (Text1), and set its Multiline property True and Font to
Courier New, the result is correct for the textbox, but shows the missing first
column for all but the first line of the label caption. This is the code I
tried, with 7 @'s for each format. Both Text1 and the debug print come out
right, and the label caption is off.

Dim intQuantity As Long
Dim curTicketPrice As Currency
Dim curFee As Currency
Dim curSubtotal As Currency

intQuantity = 24
curTicketPrice = 22.34
curFee = 2.567
curSubtotal = curTicketPrice + curFee

lblOutput3.Caption = Format(intQuantity, "@@@@@@@") & vbCrLf _
& Format(Format(curTicketPrice, "fixed"), "@@@@@@@") & vbCrLf _
& Format(Format(curFee, "fixed"), "@@@@@@@") & vbCrLf _
& Format(Format(curSubtotal, "fixed"), "@@@@@@@") & vbCrLf & vbCrLf

Text1.Text = lblOutput3.Caption

Debug.Print lblOutput3.Caption

So, try a locked text box instead of a label. Or maybe just a label with
alignment set to right justify? Otherwise, no explanation, except to say that it
is the label, not the code.
Jul 17 '05 #25

P: n/a

"Steve Gerrard" <no*************@comcast.net> wrote in message
news:8t********************@comcast.com...

"Adrian Parker" <no@addy.com> wrote in message
news:wh****************@news20.bellglobal.com...

"Steve Gerrard" <no*************@comcast.net> wrote in message
news:Ke********************@comcast.com...

"Adrian Parker" <no@addy.com> wrote in message
news:1y****************@news20.bellglobal.com...
>
> "Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message
> news:LK********************@comcast.com...

You're right. Sorry about the red herring.

I tried your code and got the same odd result, and was able to show that it is an odd property of the label.

If you add a textbox (Text1), and set its Multiline property True and Font to Courier New, the result is correct for the textbox, but shows the missing first column for all but the first line of the label caption. This is the code I
tried, with 7 @'s for each format. Both Text1 and the debug print come out
right, and the label caption is off.

Dim intQuantity As Long
Dim curTicketPrice As Currency
Dim curFee As Currency
Dim curSubtotal As Currency

intQuantity = 24
curTicketPrice = 22.34
curFee = 2.567
curSubtotal = curTicketPrice + curFee

lblOutput3.Caption = Format(intQuantity, "@@@@@@@") & vbCrLf _
& Format(Format(curTicketPrice, "fixed"), "@@@@@@@") & vbCrLf _
& Format(Format(curFee, "fixed"), "@@@@@@@") & vbCrLf _
& Format(Format(curSubtotal, "fixed"), "@@@@@@@") & vbCrLf & vbCrLf
Text1.Text = lblOutput3.Caption

Debug.Print lblOutput3.Caption

So, try a locked text box instead of a label. Or maybe just a label with
alignment set to right justify? Otherwise, no explanation, except to say that it is the label, not the code.

Is there any way to report this bug to Microsoft?

Adrian
Jul 17 '05 #26

P: n/a

"Adrian Parker" <no@addy.com> wrote in message
news:IQ*****************@news20.bellglobal.com...

"Steve Gerrard" <no*************@comcast.net> wrote in message
news:8t********************@comcast.com...

"Adrian Parker" <no@addy.com> wrote in message
news:wh****************@news20.bellglobal.com...

"Steve Gerrard" <no*************@comcast.net> wrote in message
news:Ke********************@comcast.com...
>
> "Adrian Parker" <no@addy.com> wrote in message
> news:1y****************@news20.bellglobal.com...
> >
> > "Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message
> > news:LK********************@comcast.com...


You're right. Sorry about the red herring.

I tried your code and got the same odd result, and was able to show that

it is
an odd property of the label.

If you add a textbox (Text1), and set its Multiline property True and Font

to
Courier New, the result is correct for the textbox, but shows the missing

first
column for all but the first line of the label caption. This is the code I
tried, with 7 @'s for each format. Both Text1 and the debug print come out
right, and the label caption is off.

Dim intQuantity As Long
Dim curTicketPrice As Currency
Dim curFee As Currency
Dim curSubtotal As Currency

intQuantity = 24
curTicketPrice = 22.34
curFee = 2.567
curSubtotal = curTicketPrice + curFee

lblOutput3.Caption = Format(intQuantity, "@@@@@@@") & vbCrLf _
& Format(Format(curTicketPrice, "fixed"), "@@@@@@@") & vbCrLf _
& Format(Format(curFee, "fixed"), "@@@@@@@") & vbCrLf _
& Format(Format(curSubtotal, "fixed"), "@@@@@@@") & vbCrLf &

vbCrLf

Text1.Text = lblOutput3.Caption

Debug.Print lblOutput3.Caption

So, try a locked text box instead of a label. Or maybe just a label with
alignment set to right justify? Otherwise, no explanation, except to say

that it
is the label, not the code.

Is there any way to report this bug to Microsoft?

Adrian


I doubt it, since I think they are dropping further support for VB 6 in favor of
VB.Net anyway.
Jul 17 '05 #27

This discussion thread is closed

Replies have been disabled for this discussion.