Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Questions about aligning fields Please help.....

Status
Not open for further replies.

tigerlilly

Technical User
Mar 30, 2004
7
US
I am trying aligning my columns and getting rid of the decimal points I have it now defined as currency, but it is supposed to be a number W/O decimals. My code is below. Can someone please help me?? Thank you!!!

Private Sub DisplayHeader()
txtschedule.Text = RightAlign("EOY", cfEOYvaluewidth) & _
RightAlign("Accum", cfAccumDepwidth) & vbNewLine & _
RightAlign("Year", cfyearswidth) & _
RightAlign("Depr", cfdeprwidth) & _
RightAlign("Value", cfEOYvaluewidth) & _
RightAlign("Depr", cfdeprwidth)
End Sub

'Build the formated detail line and add to the text box
txtschedule.Text = txtschedule.Text & vbNewLine & _
RightAlign(Format(I, "0.00"), cfyearswidth) & _
RightAlign(Format(fdepr, "0.00"), cfdeprwidth) & _
RightAlign(Format(feoyvalue, "0.00"), cfEOYvaluewidth) & _
RightAlign(Format(faccumdepr, "0.00"), cfAccumDepwidth)

Next I
End Sub

How do I get the columns to align?
I have 4 columns
Column 1 is Year
Column 2 is Depr
Column 3 is EOY value
Column 4 is Accum Depr
 
Hi,
1) One problem with aligning text is variable width Fonts(4's are wider than 1's).Change the textbox font to a fixed width(tpyewriter)font such as Courier.
2) To remove the decimal you can you the Replace statement e.g.
Replace(fdepr, ".", "")
3) To make all fields the same width use the Space statement to add padding to the front of the string e.g.
str = Space(12 - Len(I)) & I
To put it all together.
str = Space(12 - Len(I)) & Replace(I, ".", "")
str = str & Space(12 - Len(fdepr)) & Replace(fdepr, ".", "")
str = str & Space(12 - Len(faccumdepr)) & Replace(faccumdepr, ".", "")
str = str & Space(12 - Len(feoyvalue)) & Replace(feoyvalue, ".", "")
Text2.Text = str

Jon

P.S.
Why are you using TextBoxes and not Labels
 
Thanks Jon I am still having trouble though.
I still don't understand. The column headings need to display like this:
EOY Accum
Year Depr Value Depr

How do I do this?
 
Hi tigerlilly,

Why is it that you are trying to align these heading in one big TextBox ? Wouldn't be easier to use individual boxes for each or Labels? In either case you could use the alignment properties of each box/label and place each control on the form where you need them

Jon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top