注册 登录
编程论坛 VB6论坛

Load text

yuk_yu 发布于 2016-01-22 14:55, 1441 次点击
我想一次自动load text1(20), 将text控件自动均匀分布到4列, 每列5个, 宽度为Form1的4/1, 高度=2000, 如何能实现? 我试了多次都分布不好,请大家帮忙写个循环,谢谢

      For j = 0 To 19 Step 5
            Debug.Print j
            For i = 0 To 4
                Load Text1(j + i)
                Text1(j + i).Visible = True
                Text1(j + i).Top = Text1(j + i).Top + Text1(0).Height
                Text1(j + i).Left=??
            Next
        Next
只有本站会员才能查看附件,请 登录


[此贴子已经被作者于2016-1-22 15:08编辑过]

2 回复
#2
wmf20142016-01-22 17:45
Private Sub Form_Load()
  Dim i As Integer, w As Integer, h As Integer, l As Integer, t As Integer
  On Error Resume Next
  l = 150: t = 150
  w = (Me.ScaleWidth - 2 * l) / 4 - 30
  h = 600
  For i = 0 To 19
    If i > 0 Then Load Text1(i)
    If i <> 0 And (i Mod 4) = 0 Then
      l = 150
      t = t + h + 300
    End If
    Text1(i).Left = l
    Text1(i).Top = t
    Text1(i).Width = w
    Text1(i).Height = h
    Text1(i).Visible = True
    l = l + w + 30
  Next
End Sub
#3
yangfrancis2016-01-23 23:50
Const WIDTH=???
Const HEIGHT=???
For i=0 To 19
   Text1(i).Left=Round(WIDTH*(i Mod 4))
   Text1(i).Top=Round(HEIGHT*(i\4))
Next i
'未测试过,自己试看行不行
1