Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi again everyone.

I have input from a database which consists of a Description and a currency Amount.

I have to put these descriptions and amounts into an email (or NotePad type sheet) in columns and I am going crazy trying to get the amounts to line up.

The descriptions may be EG:

aaaaaaaaaa
AAAAAAAAAA

and the amounts 99.99 and 120.55 respectively. Note that there are 10 a's in each description.

if I use something like :
VB
theString = Description & " - " & Amount

in a loop then I end up with columns that are not aligned like:

aaaaaaaaaa - 99.99
AAAAAAAAAA - 120.55

Using the .Length attribute is pointless because both Description strings are 10 characters in length.

Could someone please suggest how I could do this.
I have tried using padding and FixedLength but to no avail.
I have also tried using tabs (Chr(9)) but that also does not work because the lengths of Description are the same.
Posted
Updated 24-Oct-14 0:54am
v2
Comments
Maciej Los 24-Oct-14 6:57am    
It depends on many factors. Does email application supports rtf of html format?
Darrell de Wet 24-Oct-14 7:03am    
Hi. It is currently HTML. But problem still exists if I write to NotePad.
Maciej Los 24-Oct-14 7:51am    
Please, see my answer.
Next time, please use 'Reply' widget, then i'll be informed via notification system about your reply.

There are only two ways to "line things up":
1) You need to specify the font: you need a "non-proportional" font - which means all teh characters are the same width. So "i" is the same as "W". Courier is a good choice, and it's on most systems.
2) You need to be able to specify tab points in non-character increments: pixels perhaps, or millimeters. This is harder, as it depends on teh application.

Me? I'd use Courier!
The HTML for that would be:
HTML
Normal <span><FONT FACE= "Courier New">Courier</span>
 
Share this answer
 
Comments
Darrell de Wet 24-Oct-14 7:33am    
Again you came through. Thanks a million - font never even crossed my mind. Works perfectly. And to think I have sweated for many hours over this.
OriginalGriff 24-Oct-14 8:24am    
You're welcome!
Thank you for clarification.

If email client supports html format, put the data between html (table) tags:
HTML
<table>
<!-- headers -->
<tr><th>Description</th><th>Amount</th></tr>
<!-- rows -->
<tr><td>AAAAAAAA</td><td>99</td></tr>
<tr><td>aaaaaaa</td><td>126</td></tr>
</table>


Result:

DescriptionAmount
AAAAAAAA99
aaaaaaa126
 
Share this answer
 
Comments
Darrell de Wet 24-Oct-14 8:03am    
My HTML skills are almost non existent but I see what you are saying.
I am going to give it a try.

thanks very much for your time and effort
Maciej Los 24-Oct-14 8:51am    
You're very welcome ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900