how do you format labels in VB?

GoingUp

Lifer
Jul 31, 2002
16,720
1
71
Need to format a list so that it appears

object 1 object 2
1 2
3 4
5 6


How do you format it so that you get it in a label to appear like that? I cant get it to work... the vbTab does nothing for me... is there another way?
 

Evadman

Administrator Emeritus<br>Elite Member
Feb 18, 2001
30,990
5
81
I am confused. Could you elaborate a little more?
 

GoingUp

Lifer
Jul 31, 2002
16,720
1
71
visual basic...

I want to format into columns just like above...

vbTab isnt working....
 

minendo

Elite Member
Aug 31, 2001
35,558
16
81
Originally posted by: Gobadgrs
visual basic...

I want to format into columns just like above...

vbTab isnt working....
Make sure you use Courier New font.

 

Descartes

Lifer
Oct 10, 1999
13,968
2
0
Labels can't display tabs, so do use Space() instead.

e.g.: yourLabel.Caption = "1" & Space(4) & "2"
 

GoingUp

Lifer
Jul 31, 2002
16,720
1
71
Originally posted by: Descartes
Labels can't display tabs, so do use Space() instead.

e.g.: yourLabel.Caption = "1" & Space(4) & "2"

Thanks!

maybe you can help me with my next part of the code... it keeps looking for a end of statement and I dont know why

If sentry = True Then 'prevents program crashing from blank values

sludge = sludgeVolume
cost = costPerTon
yearlyDisposal = 52 * sludgeVolume * costPerTon 'Math calculations
yearlySavings = yearlyDisposal * 0.6

Dim output As String

output = "Year" & vbTab & "Yearly Disposal Costs" & vbTab & "Annual Increase in Profits" vbCrLf & _
"1" & Format(yearlyDisposal, "currency") & Format(yearlySavings, "currency") vbCrLf & _
"2" & Format(yearlyDisposal * 1.02, "currency") & Format(yearlySavings * 1.02, "currency") vbCrLf & _
"3" & Format(yearlyDisposal * 1.02, "currency") & Format(yearlySavings * 1.02, "currency") vbCrLf & _
"4" & Format(yearlyDisposal * 1.02, "currency") & Format(yearlySavings * 1.02, "currency") vbCrLf & _
"5" & Format(yearlyDisposal * 1.02, "currency") & Format(yearlySavings * 1.02, "currency") vbCrLf & _
"6" & Format(yearlyDisposal * 1.02, "currency") & Format(yearlySavings * 1.02, "currency") vbCrLf & _
"7" & Format(yearlyDisposal * 1.02, "currency") & Format(yearlySavings * 1.02, "currency") vbCrLf & _
"8" & Format(yearlyDisposal * 1.02, "currency") & Format(yearlySavings * 1.02, "currency") vbCrLf & _
"9" & Format(yearlyDisposal * 1.02, "currency") & Format(yearlySavings * 1.02, "currency")vbCrLf & _
"10" & vbTab & Format(yearlyDisposal * 1.02, "currency") & Format(yearlySavings * 1.02, "currency")

yearlyDisplay.Text = output

End If
 

Descartes

Lifer
Oct 10, 1999
13,968
2
0
Originally posted by: minendo
Originally posted by: Gobadgrs
why does the font matter?
Some fonts do not align properly in visual basic generated tables.

Yes, but that's not his issue in this case, he needs to present them in a tabular order.
 

Descartes

Lifer
Oct 10, 1999
13,968
2
0
Originally posted by: Gobadgrs
Originally posted by: Descartes
Labels can't display tabs, so do use Space() instead.

e.g.: yourLabel.Caption = "1" & Space(4) & "2"

Thanks!

maybe you can help me with my next part of the code... it keeps looking for a end of statement and I dont know why

If sentry = True Then 'prevents program crashing from blank values

sludge = sludgeVolume
cost = costPerTon
yearlyDisposal = 52 * sludgeVolume * costPerTon 'Math calculations
yearlySavings = yearlyDisposal * 0.6

Dim output As String

output = "Year" & vbTab & "Yearly Disposal Costs" & vbTab & "Annual Increase in Profits" vbCrLf & _
"1" & Format(yearlyDisposal, "currency") & Format(yearlySavings, "currency") vbCrLf & _
"2" & Format(yearlyDisposal * 1.02, "currency") & Format(yearlySavings * 1.02, "currency") vbCrLf & _
"3" & Format(yearlyDisposal * 1.02, "currency") & Format(yearlySavings * 1.02, "currency") vbCrLf & _
"4" & Format(yearlyDisposal * 1.02, "currency") & Format(yearlySavings * 1.02, "currency") vbCrLf & _
"5" & Format(yearlyDisposal * 1.02, "currency") & Format(yearlySavings * 1.02, "currency") vbCrLf & _
"6" & Format(yearlyDisposal * 1.02, "currency") & Format(yearlySavings * 1.02, "currency") vbCrLf & _
"7" & Format(yearlyDisposal * 1.02, "currency") & Format(yearlySavings * 1.02, "currency") vbCrLf & _
"8" & Format(yearlyDisposal * 1.02, "currency") & Format(yearlySavings * 1.02, "currency") vbCrLf & _
"9" & Format(yearlyDisposal * 1.02, "currency") & Format(yearlySavings * 1.02, "currency")vbCrLf & _
"10" & vbTab & Format(yearlyDisposal * 1.02, "currency") & Format(yearlySavings * 1.02, "currency")

yearlyDisplay.Text = output

End If

You left the concatenation operator (&) off before all of the vbCrLfs. e.g.:

..."currency") & vbCrLf

That's the first thing I saw.
 

GoingUp

Lifer
Jul 31, 2002
16,720
1
71
thats why....

thanks! as much as I want to display this stuff in a label, i think im just gonna say screw it and put it in a message box...

the damn label cant format stuff in tabular order properly...

its math functions so the variables and values will change... using the stupid space(x) method wont be the same every time...