473,402 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

RSet and Fixed Length Strings

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
26 9623
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
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
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

"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

"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

"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

"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

"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
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

"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
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

"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
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

"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
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
> > 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

"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

"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
> > > > 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

"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

"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

"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

"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

"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

"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

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Tajmiester | last post by:
Hi, And thanks for any help. I am having trouble declaring a struct containing strings that can be Serialized using the following functions. It works, but the strings wont store the right number...
3
by: ecov | last post by:
Is there any easy way to read into a dataset a file that was created from a BCP command. The file is in a fixed length format. I would also like to be able to write out a dataset to the same type...
3
by: Ken Kast | last post by:
I'm using VBFixedString to create fixed length strings. But I find that the string will merrily allow a string of greater length to be assigned to it. Is this the way things are supposed to work?...
4
by: LCAdeveloper | last post by:
I have had to move to Visual Studio.NET Pro. from Visual Basic 4.0 and am now starting to re-write our code. I was a bit surprised to find that Visual Basic.NET no longer supports fixed length...
4
by: Scott Lemen | last post by:
Hi, Some Win APIs expect a structure with a fixed length string. How is it defined in VB .Net 2003? When I try to use the FixedLengthString class I get an "Array bounds cannot appear in type...
3
by: KLomax | last post by:
VB6 allowed you to define User types that you could write to file using the statement. This is a nice way to generate fixed length text files. See Below. VB.NET does not support UserTypes with...
5
by: David Garamond | last post by:
The MySQL manual recommends that we create a "fixed-length row" if possible, for speed (especially scanning speed). A fixed-length row is a row which is comprised of only fixed-length fields. A...
4
by: taskswap | last post by:
I'm converting an application that relies heavily on a binary network protocol. Within this protocol are a lot of byte arrays of character data, like: public unsafe struct MsgAddEntry {...
1
by: Rick Knospler | last post by:
I am trying to convert a vb6 project to vb.net. The conversion worked for the most part except for the fixed length strings and fixed length string arrays. Bascially the vb6 programmer stored all...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.