vb中label怎么自动对齐?
'按","来对齐的,由于2个label的","数量可能不一样,所以都是分开处理的,数量不限按最长的分割。Option ExplicitPrivate Sub Form_Activate()Dim a, b, abmax, i
Me.Height = 3600
Me.Width = 4800
Label1.Left = 480: Label2.Left = 480
Label2.Top = 480: Label2.Top = 800
Label1.AutoSize = True
Label2.AutoSize = TrueLabel1.Caption = "1,1,1"
Label2.Caption = "11,-1,-0.5"
a = Split(Label1.Caption, ",")
b = Split(Label2.Caption, ",")For i = 0 To UBound(a)
If abmax < Len(a(i)) Then abmax = Len(a(i))
Next
For i = 0 To UBound(b)
If abmax < Len(b(i)) Then abmax = Len(b(i))
NextLabel1.Caption = ""
Label2.Caption = ""For i = 0 To UBound(a)
Label1.Caption = Label1.Caption & Space(abmax - Len(a(i))) & a(i) & ","
Next
For i = 0 To UBound(b)
Label2.Caption = Label2.Caption & Space(abmax - Len(b(i))) & b(i) & ","
Next
End Sub