vb中label怎么自动对齐

更新时间:02-03 教程 由 |唁 分享

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

声明:关于《vb中label怎么自动对齐》以上内容仅供参考,若您的权利被侵害,请联系13825271@qq.com
本文网址:http://www.25820.com/tutorial/14_2177286.html