RSet and Fixed Length Strings

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Adrian Parker

    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(intQuant ity, "General Number")
    RSet strTicketPrice = Format(curTicke tPrice, "fixed")
    RSet strFee = Format(curFee, "fixed")
    RSet strSubtotal = Format(curSubto tal, "fixed")
    RSet strDiscount = Format(curDisco unt, "fixed")
    RSet strTaxes = Format(curTaxes , "fixed")
    RSet strTotal = Format(curTotal , "currency")




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


  • Rick Rothstein

    #2
    Re: RSet and Fixed Length Strings

    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:Bqxob.5885 $Nm6.383823@new s20.bellglobal. com...[color=blue]
    > 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[/color]
    the[color=blue]
    > 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(intQuant ity, "General Number")
    > RSet strTicketPrice = Format(curTicke tPrice, "fixed")
    > RSet strFee = Format(curFee, "fixed")
    > RSet strSubtotal = Format(curSubto tal, "fixed")
    > RSet strDiscount = Format(curDisco unt, "fixed")
    > RSet strTaxes = Format(curTaxes , "fixed")
    > RSet strTotal = Format(curTotal , "currency")
    >
    >
    >
    >
    > <Ade
    > --
    > Adrian Parker. Ordained priest. <adrian.parker@ sympatico.ca>
    > Want to know the purpose of life? I'd be happy to share it with you...
    >
    >[/color]


    Comment

    • Adrian Parker

      #3
      Re: RSet and Fixed Length Strings

      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" <rickNOSPAMnews @NOSPAMcomcast. net> wrote in message
      news:CYedne-H-N12ND-iRVn-tQ@comcast.com. ..[color=blue]
      > 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:Bqxob.5885 $Nm6.383823@new s20.bellglobal. com...[color=green]
      > > 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[/color]
      > the[color=green]
      > > 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(intQuant ity, "General Number")
      > > RSet strTicketPrice = Format(curTicke tPrice, "fixed")
      > > RSet strFee = Format(curFee, "fixed")
      > > RSet strSubtotal = Format(curSubto tal, "fixed")
      > > RSet strDiscount = Format(curDisco unt, "fixed")
      > > RSet strTaxes = Format(curTaxes , "fixed")
      > > RSet strTotal = Format(curTotal , "currency")
      > >
      > >
      > >
      > >
      > > <Ade
      > > --
      > > Adrian Parker. Ordained priest. <adrian.parker@ sympatico.ca>
      > > Want to know the purpose of life? I'd be happy to share it with you...
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Rick Rothstein

        #4
        Re: RSet and Fixed Length Strings

        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

        SevenPlacesRtJu st = Right$(" " & VariableSizeStr ing, 7)

        where VariableSizeStr ing could be Format$(curTota l, "currency") as an
        example; or, as another alternative, this

        SevenPlacesRtJu st = Format$(Variabl eSizeString, "@@@@@@@")

        where, again, VariableSizeStr ing could be Format$(curTota l, "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:oXxob.5919 $Nm6.385568@new s20.bellglobal. com...[color=blue]
        > 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" <rickNOSPAMnews @NOSPAMcomcast. net> wrote in message
        > news:CYedne-H-N12ND-iRVn-tQ@comcast.com. ..[color=green]
        > > 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[/color][/color]
        perhaps[color=blue][color=green]
        > > forgetting to count the decimal point along with the other characters?
        > >
        > > Rick - MVP
        > >
        > >
        > > "Adrian Parker" <no@addy.com> wrote in message
        > > news:Bqxob.5885 $Nm6.383823@new s20.bellglobal. com...[color=darkred]
        > > > I'm using the code below in my project. When I print all of these[/color][/color][/color]
        fixed[color=blue][color=green][color=darkred]
        > > > length string variables, one per line, they strings in questions do[/color][/color][/color]
        not[color=blue][color=green][color=darkred]
        > > > properly pad with 0s. strQuantity prints as " 4". Six spaces[/color][/color][/color]
        than[color=blue][color=green]
        > > the[color=darkred]
        > > > value of intQuantity. This is correct.
        > > >
        > > > But all the others end up being string objects of only 6 characters[/color][/color][/color]
        long[color=blue][color=green][color=darkred]
        > > > (with the exception of strTotal). The left most positions of the[/color][/color][/color]
        string[color=blue][color=green][color=darkred]
        > > > object are being padded with one too few spaces. How is this[/color][/color][/color]
        possible?[color=blue][color=green][color=darkred]
        > > >
        > > >
        > > >
        > > > 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(intQuant ity, "General Number")
        > > > RSet strTicketPrice = Format(curTicke tPrice, "fixed")
        > > > RSet strFee = Format(curFee, "fixed")
        > > > RSet strSubtotal = Format(curSubto tal, "fixed")
        > > > RSet strDiscount = Format(curDisco unt, "fixed")
        > > > RSet strTaxes = Format(curTaxes , "fixed")
        > > > RSet strTotal = Format(curTotal , "currency")
        > > >
        > > >
        > > >
        > > >
        > > > <Ade
        > > > --
        > > > Adrian Parker. Ordained priest. <adrian.parker@ sympatico.ca>
        > > > Want to know the purpose of life? I'd be happy to share it with[/color][/color][/color]
        you...[color=blue][color=green][color=darkred]
        > > >
        > > >[/color]
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Adrian Parker

          #5
          Re: RSet and Fixed Length Strings


          "Rick Rothstein" <rickNOSPAMnews @NOSPAMcomcast. net> wrote in message
          news:SJCdnVmmKt 56KD-iRVn-jg@comcast.com. ..[color=blue]
          > 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[/color]
          perspective,[color=blue]
          > there is nothing wrong with you code.
          >
          > Is there a particular reason you are using fixed-length strings in the[/color]
          first[color=blue]
          > place? If you need to print out results with a give number of characters,
          > you could do this[/color]

          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.

          [color=blue]
          > SevenPlacesRtJu st = Right$(" " & VariableSizeStr ing, 7)
          >
          > where VariableSizeStr ing could be Format$(curTota l, "currency") as an
          > example; or, as another alternative, this
          >
          > SevenPlacesRtJu st = Format$(Variabl eSizeString, "@@@@@@@")
          >
          > where, again, VariableSizeStr ing could be Format$(curTota l, "currency") as
          > an example. Yes, that would be a Format$ function inside a Format$[/color]
          function.[color=blue]
          > In the first statement above, that is 7 blank spaces between the quotes;[/color]
          in[color=blue]
          > the second statement, that is 7 "at" signs.
          >
          > Rick - MVP
          >
          > "Adrian Parker" <no@addy.com> wrote in message
          > news:oXxob.5919 $Nm6.385568@new s20.bellglobal. com...[color=green]
          > > No, I counted the decimal point.
          > >
          > > One of the outputs, for example, is " 23.63". One space, five[/color][/color]
          characters[color=blue][color=green]
          > > after the space. And this is a String object with a fixed length of 7.
          > >
          > >
          > > Adrian
          > >
          > >
          > >
          > >
          > > "Rick Rothstein" <rickNOSPAMnews @NOSPAMcomcast. net> wrote in message
          > > news:CYedne-H-N12ND-iRVn-tQ@comcast.com. ..[color=darkred]
          > > > 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[/color][/color]
          > perhaps[color=green][color=darkred]
          > > > forgetting to count the decimal point along with the other characters?
          > > >
          > > > Rick - MVP
          > > >
          > > >
          > > > "Adrian Parker" <no@addy.com> wrote in message
          > > > news:Bqxob.5885 $Nm6.383823@new s20.bellglobal. com...
          > > > > I'm using the code below in my project. When I print all of these[/color][/color]
          > fixed[color=green][color=darkred]
          > > > > length string variables, one per line, they strings in questions do[/color][/color]
          > not[color=green][color=darkred]
          > > > > properly pad with 0s. strQuantity prints as " 4". Six spaces[/color][/color]
          > than[color=green][color=darkred]
          > > > the
          > > > > value of intQuantity. This is correct.
          > > > >
          > > > > But all the others end up being string objects of only 6 characters[/color][/color]
          > long[color=green][color=darkred]
          > > > > (with the exception of strTotal). The left most positions of the[/color][/color]
          > string[color=green][color=darkred]
          > > > > object are being padded with one too few spaces. How is this[/color][/color]
          > possible?[color=green][color=darkred]
          > > > >
          > > > >
          > > > >
          > > > > 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(intQuant ity, "General Number")
          > > > > RSet strTicketPrice = Format(curTicke tPrice, "fixed")
          > > > > RSet strFee = Format(curFee, "fixed")
          > > > > RSet strSubtotal = Format(curSubto tal, "fixed")
          > > > > RSet strDiscount = Format(curDisco unt, "fixed")
          > > > > RSet strTaxes = Format(curTaxes , "fixed")
          > > > > RSet strTotal = Format(curTotal , "currency")
          > > > >
          > > > >
          > > > >
          > > > >
          > > > > <Ade
          > > > > --
          > > > > Adrian Parker. Ordained priest. <adrian.parker@ sympatico.ca>
          > > > > Want to know the purpose of life? I'd be happy to share it with[/color][/color]
          > you...[color=green][color=darkred]
          > > > >
          > > > >
          > > >
          > > >[/color]
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • Adrian Parker

            #6
            Re: RSet and Fixed Length Strings


            "Rick Rothstein" <rickNOSPAMnews @NOSPAMcomcast. net> wrote in message
            news:SJCdnVmmKt 56KD-iRVn-jg@comcast.com. ..[color=blue]
            > 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[/color]
            perspective,[color=blue]
            > there is nothing wrong with you code.
            >
            > Is there a particular reason you are using fixed-length strings in the[/color]
            first[color=blue]
            > place? If you need to print out results with a give number of characters,
            > you could do this
            >
            > SevenPlacesRtJu st = Right$(" " & VariableSizeStr ing, 7)[/color]

            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.

            ?



            [color=blue]
            > where VariableSizeStr ing could be Format$(curTota l, "currency") as an
            > example; or, as another alternative, this
            >
            > SevenPlacesRtJu st = Format$(Variabl eSizeString, "@@@@@@@")
            >
            > where, again, VariableSizeStr ing could be Format$(curTota l, "currency") as
            > an example. Yes, that would be a Format$ function inside a Format$[/color]
            function.[color=blue]
            > In the first statement above, that is 7 blank spaces between the quotes;[/color]
            in[color=blue]
            > the second statement, that is 7 "at" signs.
            >
            > Rick - MVP
            >
            > "Adrian Parker" <no@addy.com> wrote in message
            > news:oXxob.5919 $Nm6.385568@new s20.bellglobal. com...[color=green]
            > > No, I counted the decimal point.
            > >
            > > One of the outputs, for example, is " 23.63". One space, five[/color][/color]
            characters[color=blue][color=green]
            > > after the space. And this is a String object with a fixed length of 7.
            > >
            > >
            > > Adrian
            > >
            > >
            > >
            > >
            > > "Rick Rothstein" <rickNOSPAMnews @NOSPAMcomcast. net> wrote in message
            > > news:CYedne-H-N12ND-iRVn-tQ@comcast.com. ..[color=darkred]
            > > > 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[/color][/color]
            > perhaps[color=green][color=darkred]
            > > > forgetting to count the decimal point along with the other characters?
            > > >
            > > > Rick - MVP
            > > >
            > > >
            > > > "Adrian Parker" <no@addy.com> wrote in message
            > > > news:Bqxob.5885 $Nm6.383823@new s20.bellglobal. com...
            > > > > I'm using the code below in my project. When I print all of these[/color][/color]
            > fixed[color=green][color=darkred]
            > > > > length string variables, one per line, they strings in questions do[/color][/color]
            > not[color=green][color=darkred]
            > > > > properly pad with 0s. strQuantity prints as " 4". Six spaces[/color][/color]
            > than[color=green][color=darkred]
            > > > the
            > > > > value of intQuantity. This is correct.
            > > > >
            > > > > But all the others end up being string objects of only 6 characters[/color][/color]
            > long[color=green][color=darkred]
            > > > > (with the exception of strTotal). The left most positions of the[/color][/color]
            > string[color=green][color=darkred]
            > > > > object are being padded with one too few spaces. How is this[/color][/color]
            > possible?[color=green][color=darkred]
            > > > >
            > > > >
            > > > >
            > > > > 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(intQuant ity, "General Number")
            > > > > RSet strTicketPrice = Format(curTicke tPrice, "fixed")
            > > > > RSet strFee = Format(curFee, "fixed")
            > > > > RSet strSubtotal = Format(curSubto tal, "fixed")
            > > > > RSet strDiscount = Format(curDisco unt, "fixed")
            > > > > RSet strTaxes = Format(curTaxes , "fixed")
            > > > > RSet strTotal = Format(curTotal , "currency")
            > > > >
            > > > >
            > > > >
            > > > >
            > > > > <Ade
            > > > > --
            > > > > Adrian Parker. Ordained priest. <adrian.parker@ sympatico.ca>
            > > > > Want to know the purpose of life? I'd be happy to share it with[/color][/color]
            > you...[color=green][color=darkred]
            > > > >
            > > > >
            > > >
            > > >[/color]
            > >
            > >[/color]
            >
            >[/color]


            Comment

            • Adrian Parker

              #7
              Re: RSet and Fixed Length Strings


              "Rick Rothstein" <rickNOSPAMnews @NOSPAMcomcast. net> wrote in message
              news:SJCdnVmmKt 56KD-iRVn-jg@comcast.com. ..
              [color=blue]
              > SevenPlacesRtJu st = Format$(Variabl eSizeString, "@@@@@@@")[/color]

              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


              Comment

              • Adrian Parker

                #8
                Re: RSet and Fixed Length Strings


                "Adrian Parker" <no@addy.com> wrote in message
                news:IcCob.1114 8$Tf.1210131@ne ws20.bellglobal .com...[color=blue]
                >
                > "Rick Rothstein" <rickNOSPAMnews @NOSPAMcomcast. net> wrote in message
                > news:SJCdnVmmKt 56KD-iRVn-jg@comcast.com. ..
                >[color=green]
                > > SevenPlacesRtJu st = Format$(Variabl eSizeString, "@@@@@@@")[/color]
                >
                > 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.[/color]

                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


                Comment

                • Steve Gerrard

                  #9
                  Re: RSet and Fixed Length Strings


                  "Adrian Parker" <no@addy.com> wrote in message
                  news:nuCob.1115 5$Tf.1212910@ne ws20.bellglobal .com...[color=blue]
                  >
                  > "Adrian Parker" <no@addy.com> wrote in message
                  > news:IcCob.1114 8$Tf.1210131@ne ws20.bellglobal .com...[color=green]
                  > >
                  > > "Rick Rothstein" <rickNOSPAMnews @NOSPAMcomcast. net> wrote in message
                  > > news:SJCdnVmmKt 56KD-iRVn-jg@comcast.com. ..
                  > >[color=darkred]
                  > > > SevenPlacesRtJu st = Format$(Variabl eSizeString, "@@@@@@@")[/color]
                  > >
                  > > 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.[/color]
                  >
                  > 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
                  >
                  >[/color]

                  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.


                  Comment

                  • Rick Rothstein

                    #10
                    Re: RSet and Fixed Length Strings

                    You've raised several questions which I've combined into this one message.
                    See my inline comments...
                    [color=blue]
                    > 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.[/color]

                    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?

                    [color=blue]
                    > 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.[/color]

                    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?

                    [color=blue][color=green][color=darkred]
                    > > > SevenPlacesRtJu st = Format$(Variabl eSizeString, "@@@@@@@")[/color]
                    > >
                    > > 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.[/color]
                    >
                    > Sorry, it does work. But the output is strange.
                    >[/color]
                    [color=blue]
                    > ''''''''''''''' ''''''''''''''' ''''' 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.[/color]

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


                    Rick - MVP



                    Comment

                    • Adrian Parker

                      #11
                      Re: RSet and Fixed Length Strings


                      "Rick Rothstein" <rickNOSPAMnews @NOSPAMcomcast. net> wrote in message
                      news:NYCdnUXLre 2ahj6iRVn-sQ@comcast.com. ..[color=blue]
                      > You've raised several questions which I've combined into this one message.
                      > See my inline comments...
                      >[color=green]
                      > > 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.[/color]
                      >
                      > 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[/color]
                      a[color=blue]
                      > "ragged" right side?
                      >
                      >[color=green]
                      > > 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.[/color]
                      >
                      > 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?[/color]

                      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.

                      [color=blue][color=green][color=darkred]
                      > > > > SevenPlacesRtJu st = Format$(Variabl eSizeString, "@@@@@@@")
                      > > >
                      > > > 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.[/color]
                      > >
                      > > Sorry, it does work. But the output is strange.
                      > >[/color]
                      >[color=green]
                      > > ''''''''''''''' ''''''''''''''' ''''' 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.[/color]
                      >
                      > This will require you to use a fixed-width font instead of a
                      > proportionally-spaced font. Try using Courier New.[/color]

                      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.Capt ion = Format(intQuant ity, "@@@@@@@") & vbNewLine _
                      & Format(Format(c urTicketPrice, "fixed"), "@@@@@@@@") & vbNewLine _
                      & Format(Format(c urFee, "fixed"), "@@@@@@@@") & vbNewLine _
                      & Format(Format(c urSubtotal, "fixed"), "@@@@@@@@") & vbNewLine &
                      vbNewLine

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

                      lblOutput3.Capt ion = lblOutput3.Capt ion _
                      & Format(Format(c urTaxes, "fixed"), "@@@@@@@@") & vbNewLine _
                      & Format(Format(c urTotal, "currency") , "@@@@@@@")


                      Adrian


                      Comment

                      • J French

                        #12
                        Re: RSet and Fixed Length Strings

                        On Fri, 31 Oct 2003 13:00:05 -0500, "Adrian Parker" <no@addy.com>
                        wrote:
                        [color=blue]
                        >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.[/color]

                        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

                        Comment

                        • Adrian Parker

                          #13
                          Re: RSet and Fixed Length Strings


                          "J French" <erewhon@nowher e.com> wrote in message
                          news:3fa374db.1 56335743@news.b tclick.com...[color=blue]
                          > On Fri, 31 Oct 2003 13:00:05 -0500, "Adrian Parker" <no@addy.com>
                          > wrote:
                          >[color=green]
                          > >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[/color][/color]
                          the[color=blue][color=green]
                          > >value of intQuantity. This is correct.[/color]
                          >
                          > 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[/color]

                          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.Capt ion = Format(intQuant ity, "@@@@@@@") & vbNewLine _
                          & Format(Format(c urTicketPrice, "fixed"), "@@@@@@@@") & vbNewLine _
                          & Format(Format(c urFee, "fixed"), "@@@@@@@@") & vbNewLine _
                          & Format(Format(c urSubtotal, "fixed"), "@@@@@@@@") & vbNewLine &
                          vbNewLine

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

                          lblOutput3.Capt ion = lblOutput3.Capt ion _
                          & Format(Format(c urTaxes, "fixed"), "@@@@@@@@") & vbNewLine _
                          & Format(Format(c urTotal, "currency") , "@@@@@@@")



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



                          Adrian


                          Comment

                          • Rick Rothstein

                            #14
                            Re: RSet and Fixed Length Strings

                            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:xoHob.6068 $Nm6.430382@new s20.bellglobal. com...[color=blue]
                            >
                            > "Rick Rothstein" <rickNOSPAMnews @NOSPAMcomcast. net> wrote in message
                            > news:NYCdnUXLre 2ahj6iRVn-sQ@comcast.com. ..[color=green]
                            > > You've raised several questions which I've combined into this one[/color][/color]
                            message.[color=blue][color=green]
                            > > See my inline comments...
                            > >[color=darkred]
                            > > > 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.[/color]
                            > >
                            > > You didn't mention this originally. Are you looking for trailing zeroes[/color][/color]
                            in[color=blue][color=green]
                            > > order "fill out" the right side of each number? Or are you looking to[/color][/color]
                            have[color=blue]
                            > a[color=green]
                            > > "ragged" right side?
                            > >
                            > >[color=darkred]
                            > > > 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.[/color]
                            > >
                            > > You have to know something about the width of the numbers or you won't[/color][/color]
                            be[color=blue][color=green]
                            > > able to tell how to place them so their decimal points line up, right?[/color]
                            >
                            > Hence I make a fixed length string, larger than they can be, and right[/color]
                            align[color=blue]
                            > it.
                            >
                            > All numbers will have two decimal places. The first one doesn't, but[/color]
                            don't[color=blue]
                            > worry about it's alignment.
                            >
                            >[color=green][color=darkred]
                            > > > > > SevenPlacesRtJu st = Format$(Variabl eSizeString, "@@@@@@@")
                            > > > >
                            > > > > 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.
                            > > >[/color]
                            > >[color=darkred]
                            > > > ''''''''''''''' ''''''''''''''' ''''' 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.[/color]
                            > >
                            > > This will require you to use a fixed-width font instead of a
                            > > proportionally-spaced font. Try using Courier New.[/color]
                            >
                            > When I try with fixed with the first record is fine. All the other[/color]
                            records[color=blue]
                            > (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[/color]
                            second[color=blue]
                            > 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.Capt ion = Format(intQuant ity, "@@@@@@@") & vbNewLine _
                            > & Format(Format(c urTicketPrice, "fixed"), "@@@@@@@@") & vbNewLine[/color]
                            _[color=blue]
                            > & Format(Format(c urFee, "fixed"), "@@@@@@@@") & vbNewLine _
                            > & Format(Format(c urSubtotal, "fixed"), "@@@@@@@@") & vbNewLine &
                            > vbNewLine
                            >
                            > If curDiscount <> " 0.00" Then
                            > lblOutput3.Capt ion = lblOutput3.Capt ion _
                            > & Format(Format(c urDiscount, "fixed"), "@@@@@@@") & vbNewLine[/color]
                            &[color=blue]
                            > vbNewLine
                            > End If
                            >
                            > lblOutput3.Capt ion = lblOutput3.Capt ion _
                            > & Format(Format(c urTaxes, "fixed"), "@@@@@@@@") & vbNewLine _
                            > & Format(Format(c urTotal, "currency") , "@@@@@@@")
                            >
                            >
                            > Adrian
                            >
                            >[/color]


                            Comment

                            • Adrian Parker

                              #15
                              Re: RSet and Fixed Length Strings


                              "Rick Rothstein" <rickNOSPAMnews @NOSPAMcomcast. net> wrote in message
                              news:Br6dnbSUd6 sefD6iRVn-gw@comcast.com. ..[color=blue]
                              > 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?[/color]


                              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.Capt ion = Format(intQuant ity, "@@@@@@@") & vbNewLine _
                              & Format(Format(c urTicketPrice, "fixed"), "@@@@@@@") & vbNewLine _
                              & Format(Format(c urFee, "fixed"), "@@@@@@@") & vbNewLine _
                              & Format(Format(c urSubtotal, "fixed"), "@@@@@@@") & vbNewLine &
                              vbNewLine

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

                              lblOutput3.Capt ion = lblOutput3.Capt ion _
                              & Format(Format(c urTaxes, "fixed"), "@@@@@@@") & vbNewLine _
                              & Format(Format(c urTotal, "currency") , "@@@@@@@")


                              Where:
                              intQuantity = 1
                              curTicketPrice = 150
                              curFee = 30
                              curSubtotal = 630
                              curDiscount = 60
                              curTaxes = 85.5
                              curTotal = 655.5

                              [color=blue]
                              >
                              > Rick - MVP
                              >
                              > "Adrian Parker" <no@addy.com> wrote in message
                              > news:xoHob.6068 $Nm6.430382@new s20.bellglobal. com...[color=green]
                              > >
                              > > "Rick Rothstein" <rickNOSPAMnews @NOSPAMcomcast. net> wrote in message
                              > > news:NYCdnUXLre 2ahj6iRVn-sQ@comcast.com. ..[color=darkred]
                              > > > You've raised several questions which I've combined into this one[/color][/color]
                              > message.[color=green][color=darkred]
                              > > > 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[/color][/color][/color]
                              zeroes[color=blue]
                              > in[color=green][color=darkred]
                              > > > order "fill out" the right side of each number? Or are you looking to[/color][/color]
                              > have[color=green]
                              > > a[color=darkred]
                              > > > "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[/color][/color]
                              > be[color=green][color=darkred]
                              > > > able to tell how to place them so their decimal points line up, right?[/color]
                              > >
                              > > Hence I make a fixed length string, larger than they can be, and right[/color]
                              > align[color=green]
                              > > it.
                              > >
                              > > All numbers will have two decimal places. The first one doesn't, but[/color]
                              > don't[color=green]
                              > > worry about it's alignment.
                              > >
                              > >[color=darkred]
                              > > > > > > SevenPlacesRtJu st = Format$(Variabl eSizeString, "@@@@@@@")
                              > > > > >
                              > > > > > 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.[/color]
                              > >
                              > > When I try with fixed with the first record is fine. All the other[/color]
                              > records[color=green]
                              > > (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[/color]
                              > second[color=green]
                              > > 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[/color][/color]
                              proper[color=blue][color=green]
                              > > amount of spaces, but the one following doesn't.
                              > >
                              > >
                              > > ' Using Courier new font on lblOutput3
                              > >
                              > > lblOutput3.Capt ion = Format(intQuant ity, "@@@@@@@") & vbNewLine _
                              > > & Format(Format(c urTicketPrice, "fixed"), "@@@@@@@@") &[/color][/color]
                              vbNewLine[color=blue]
                              > _[color=green]
                              > > & Format(Format(c urFee, "fixed"), "@@@@@@@@") & vbNewLine _
                              > > & Format(Format(c urSubtotal, "fixed"), "@@@@@@@@") & vbNewLine &
                              > > vbNewLine
                              > >
                              > > If curDiscount <> " 0.00" Then
                              > > lblOutput3.Capt ion = lblOutput3.Capt ion _
                              > > & Format(Format(c urDiscount, "fixed"), "@@@@@@@") &[/color][/color]
                              vbNewLine[color=blue]
                              > &[color=green]
                              > > vbNewLine
                              > > End If
                              > >
                              > > lblOutput3.Capt ion = lblOutput3.Capt ion _
                              > > & Format(Format(c urTaxes, "fixed"), "@@@@@@@@") & vbNewLine _
                              > > & Format(Format(c urTotal, "currency") , "@@@@@@@")
                              > >
                              > >
                              > > Adrian
                              > >
                              > >[/color]
                              >
                              >[/color]


                              Comment

                              Working...