473,404 Members | 2,137 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,404 software developers and data experts.

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.



Jul 17 '05 #1
4 18129
On Wed, 22 Jun 2005 21:36:30 -0700, "Rookie" <go***@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
Jul 17 '05 #2
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" <er*****@nowhere.uk> wrote in message
news:42***************@news.btopenworld.com...
On Wed, 22 Jun 2005 21:36:30 -0700, "Rookie" <go***@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


Jul 17 '05 #3
On Thu, 23 Jun 2005 18:18:52 -0700, "Rookie" <go***@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.
Jul 17 '05 #4
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" <go***@adelphia.net> wrote in message
news:l4********************@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.
:
:
:
:
:
:
:
:
:

Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mindful_Spirit | last post by:
I'm trying to set up a basic email feed back form like this, and was wondering about some basic configuration settings. I have used code from this website. I have it working just fine. I'm...
4
by: News | last post by:
I have a page with many controls. Among these controls there is a table which is a datagrid with nested repeater inside. My problem is that I can not use DataGridCommandEventArgs to get datagrid...
3
by: Luis Esteban Valencia | last post by:
A page let of work for me I commented almost all lines but nothing the code is this
2
by: Ryan Ternier | last post by:
I'm playing around with DataGrids and the Edit columns ability. I have a text area that can be anywhere from 1-8000 characters. When I add the edit capabilities to this DataGrid it displays a...
5
by: Kerry | last post by:
Please help. I need a regular expression that parses a stream of up to 450 characters into 15 separate strings of up to 30 characters each. The regex must break at newlines. Ideally, the regex...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
5
by: Ian Tedridge | last post by:
If I have 3 textboxes on a form plus 1 multiline textbox. How can I add the text from textbox 1 to 3 to the multiline textbox ? I can add the 3 textbox contents to one line of the multiline...
1
by: raghavshastri | last post by:
You are to write a C++ program to perform a statistical analysis of the blobs in an image. The image will be a grayscale image in PGM format for simplicity. Here is a sample PGM image with 10...
4
by: anniebai | last post by:
Please help me with writing a RowUpdating function in C#, I don't know how to grab the current field's value and also get the old value for one of keys (which is ProjectName for editing) of the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.