Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Formatting data in textbox??


Reply
 
Thread Tools Display Modes
  #1  
Old 09-18-2000, 01:38 PM
mastana
Guest
 
Posts: n/a
Default 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????

Reply With Quote
  #2  
Old 09-18-2000, 01:47 PM
Helmar
Guest
 
Posts: n/a
Default 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
Reply With Quote
  #3  
Old 09-18-2000, 02:11 PM
mastana
Guest
 
Posts: n/a
Default 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?????

Reply With Quote
  #4  
Old 09-18-2000, 02:29 PM
kugela
Guest
 
Posts: n/a
Default 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
Reply With Quote
  #5  
Old 09-18-2000, 09:51 PM
cbrewer cbrewer is offline
Junior Contributor
 
Join Date: Aug 2000
Location: Florida
Posts: 163
Default Re: Formatting data in textbox??

Excellent procedure.

Chuck
Reply With Quote
  #6  
Old 09-19-2000, 01:32 PM
Dazz
Guest
 
Posts: n/a
Default 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.


Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->