Help Please: Vb6.0 Aligning Columns of Numbers in a multiline textbox (Format Function) - basic.visual

This is a discussion on Help Please: Vb6.0 Aligning Columns of Numbers in a multiline textbox (Format Function) - basic.visual ; I need to display several columns of numbers in a textbox. I wish to display the columns with the decimal point position aligned vertically. I have found that the # digit placeholders do not reserve the spaces for the number ...

+ Reply to Thread
Results 1 to 5 of 5

Help Please: Vb6.0 Aligning Columns of Numbers in a multiline textbox (Format Function)

  1. Default Help Please: Vb6.0 Aligning Columns of Numbers in a multiline textbox (Format Function)

    I need to display several columns of numbers in a textbox. I wish to
    display the columns with the decimal point position aligned vertically.

    I have found that the # digit placeholders do not reserve the spaces for the
    number if the number of digits are fewer than the number of placeholders.

    My simplified example: included within a loop such that it displays two
    columns


    Text1.Text = Text1.Text & Format(x, " ###.#0") & _
    Format(y, " #,###.0") & _
    vbCrLf


    The digit place holders do not hold the places when the number of digits in
    the values of x and y are fewer than the number of place holders (#). This
    causes the columns to not align.

    I can make the columns align by placing a (0) placeholder at the most
    significant digit to the left of the decimal but then the columns are
    displayed with numbers of leading zeros depending on how many significant
    digits are actually required to display the value in a particular row.

    Example:

    00000012.01 2345 0000000000.25

    Help would be appreciated.


    I recall that this was the only method to reserve spaces for the purposes of
    alignment of columns in earlier forms of Basic and Fortran. It seems that
    VB digit placeholders only reserve spaces for actual digits of the value to
    be displayed.










  2. Default Re: Help Please: Vb6.0 Aligning Columns of Numbers in a multiline textbox (Format Function)

    On Wed, 22 Jun 2005 21:36:30 -0700, "Rookie" <gonor@adelphia.net>
    wrote:

    >I need to display several columns of numbers in a textbox. I wish to
    >display the columns with the decimal point position aligned vertically.
    >
    >I have found that the # digit placeholders do not reserve the spaces for the
    >number if the number of digits are fewer than the number of placeholders.


    Why do you want to use a Textbox ?

    Do you intend manually editing the numbers ?

    If this is just for display, then print them directly on the face of a
    Form, Picturebox or UserControl

  3. Default Re: Help Please: Vb6.0 Aligning Columns of Numbers in a multiline textbox (Format Function)

    Thanks for your Reply,

    I used a text box so I could add a vertical scroll bar as there are up to
    300 rows of data and because I am totally new to vb.

    What I really want to know is if there is a way to fix the place holders to
    main columnar alignment.

    Gary

    "J French" <erewhon@nowhere.uk> wrote in message
    news:42ba6595.89241204@news.btopenworld.com...
    > On Wed, 22 Jun 2005 21:36:30 -0700, "Rookie" <gonor@adelphia.net>
    > wrote:
    >
    >>I need to display several columns of numbers in a textbox. I wish to
    >>display the columns with the decimal point position aligned vertically.
    >>
    >>I have found that the # digit placeholders do not reserve the spaces for
    >>the
    >>number if the number of digits are fewer than the number of placeholders.

    >
    > Why do you want to use a Textbox ?
    >
    > Do you intend manually editing the numbers ?
    >
    > If this is just for display, then print them directly on the face of a
    > Form, Picturebox or UserControl





  4. Default Re: Help Please: Vb6.0 Aligning Columns of Numbers in a multiline textbox (Format Function)

    On Thu, 23 Jun 2005 18:18:52 -0700, "Rookie" <gonor@adelphia.net>
    wrote:

    >Thanks for your Reply,
    >
    >I used a text box so I could add a vertical scroll bar as there are up to
    >300 rows of data and because I am totally new to vb.
    >
    >What I really want to know is if there is a way to fix the place holders to
    >main columnar alignment.


    You really need to use some sort of Grid or the Listview for this sort
    of thing.

    However, if you insist on using a Textbox, then you could use a fixed
    font (ie: not a proportional font) typically Courier.

  5. Default Re: Help Please: Vb6.0 Aligning Columns of Numbers in a multiline textbox (Format Function)

    Use tabstops. See http://vbnet.mvps.org/code/textapi/txboxtabs.htm. No
    padding with spaces required.

    If you want a tool to help design the tabstop positions, including
    right-justified tabstops for numbers, you can use
    http://vbnet.mvps.org/code/listapi/cooltabs.htm (that utility uses a listbox
    to set the alignment code, but the "Generate" code option allows you to
    specify the tool should create code for a listbox or for a textbox). Right
    click either the header or listbox for other options.

    There is also the listview control that may be more suitable, which also
    allows sorting of each column of numbers.

    --

    Randy Birch
    MS MVP Visual Basic
    http://vbnet.mvps.org/
    ----------------------------------------------------------------------------
    Read. Decide. Sign the petition to Microsoft.
    http://classicvb.org/petition/
    ----------------------------------------------------------------------------



    "Rookie" <gonor@adelphia.net> wrote in message
    news:l42dnaPOSe9OoSffRVn-2w@adelphia.com...
    :I need to display several columns of numbers in a textbox. I wish to
    : display the columns with the decimal point position aligned vertically.
    :
    : I have found that the # digit placeholders do not reserve the spaces for
    the
    : number if the number of digits are fewer than the number of placeholders.
    :
    : My simplified example: included within a loop such that it displays two
    : columns
    :
    :
    : Text1.Text = Text1.Text & Format(x, " ###.#0") & _
    : Format(y, " #,###.0") & _
    : vbCrLf
    :
    :
    : The digit place holders do not hold the places when the number of digits
    in
    : the values of x and y are fewer than the number of place holders (#).
    This
    : causes the columns to not align.
    :
    : I can make the columns align by placing a (0) placeholder at the most
    : significant digit to the left of the decimal but then the columns are
    : displayed with numbers of leading zeros depending on how many significant
    : digits are actually required to display the value in a particular row.
    :
    : Example:
    :
    : 00000012.01 2345 0000000000.25
    :
    : Help would be appreciated.
    :
    :
    : I recall that this was the only method to reserve spaces for the purposes
    of
    : alignment of columns in earlier forms of Basic and Fortran. It seems that
    : VB digit placeholders only reserve spaces for actual digits of the value
    to
    : be displayed.
    :
    :
    :
    :
    :
    :
    :
    :
    :


+ Reply to Thread

Similar Threads

  1. MultiLine TextBox - KeyPress Question
    By Application Development in forum CSharp
    Replies: 4
    Last Post: 10-29-2007, 05:01 AM
  2. Displaying MultiLine Content in a TextBox
    By Application Development in forum CSharp
    Replies: 4
    Last Post: 09-06-2007, 10:44 AM
  3. Aligning circled numbers - problem
    By Application Development in forum Adobe Typography
    Replies: 31
    Last Post: 11-15-2006, 11:11 PM
  4. Replies: 0
    Last Post: 06-22-2005, 11:36 PM
  5. Aligning 2d array of numbers
    By Application Development in forum Perl
    Replies: 0
    Last Post: 07-31-2003, 03:17 PM