 |
 |

09-18-2000, 01:38 PM
|
|
|
Formatting data in textbox??
|
I have an access database with the structure:
Name(20)
Age(3)
Sex(1)
Address(50)
Now when I display the records in a text box, the data appears as:
mozart 20 M chvkhgodfgdfgds
beethoven 25 M ghkdfhghgkhgogjhohgfoh
Alex 18 M bfgkhkghljgjhogjho
Manish 23 M skdhfkhghgdg
How can I make this data appear symmetrical so that all the columns can fall in line and I can give proper column headings????
|
|

09-18-2000, 01:47 PM
|
|
|
Re: Formatting data in textbox??
|
Well, the simple answer to your question is to set the font of the text box to a fixed pitch font, such as courier or Line Printer.
Then you can uses spaces to space the columns out.
A better answer would be to use the grid control (which can be bound to your data source) or one of the 3rd party list boxes that support multiple columns (Such as ListPro).
Helmar B. Herman, VP ProtoProducts
|
|

09-18-2000, 02:11 PM
|
|
|
Re: Formatting data in textbox??
|
I cannot use grid control, coz I have to insert some other line text between different sets of such data.
If I use spaces to do the formatting, then I have to insert cariable number of spaces(depending upon the lenghth of name). HOW DO I GENERATE VARIABLE NUMBER OF SPACES AT RUNTIME? I can get the length og name, but how to insert spaces at runtime?????
|
|

09-18-2000, 02:29 PM
|
|
|
Re: Formatting data in textbox??
|
Generating a variable number of spaces at runtime:
I may not completely understand the context in which you are working, but here goes...
Construct a string field by field.
To do this, get the first field (name) and put it in a string.
Dim myRow as String
'Put in code to get the name here
myRow = name
'Now generate the number of spaces needed and add it.
'Note: 20 is the max length of the name field
myRow = myRow & Space(20 - Len(name))
'Now get the Age field, concatenate it to myRow, and then
'generate the spaces as above except use 3 instead of 20
Continue constructing myRow until all the desired fields are there. Then, concatenate it to the textbox text
"My fiduciary duty is to pollute as much as I legally can." -Ruben Bolling
|
|

09-18-2000, 09:51 PM
|
|
Junior Contributor
|
|
Join Date: Aug 2000
Location: Florida
Posts: 163
|
|
Re: Formatting data in textbox??
|
Excellent procedure.
Chuck
|
|

09-19-2000, 01:32 PM
|
|
|
Re: Formatting data in textbox??
|
This is ok but all that will do is give a fixed length of sting, same as doing :-
VarName = left(Text & space(20),20)
But if the font is true type, when shown in rows will still not form columns.
What I have done before is set a desired width for the string (twips maybe).
Then cycle until the text length is that length and then add a TAB to even the column.
While ListBox1.TextWidth(Text)<1000 : Text= Text & " ": Wend
Text = Text & vbTab
This will help, but it aint perfect, you really should think about one of the grid controls, don't forget than you can merge cells, so that not all rows have the same format.
Hope it help!
Live2Give.
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|