# 动态增减控制项的问题

Posted by 姜海坤 on June 18, 1999 at 23:13:05:

Option Explicit

Private Sub cmdadd_Click(index As Integer)
Dim intcount As Integer
Dim lngwidth As Long
Dim lngheight As Long
intcount = cmdbutton.Count
lngwidth = cmdbutton(0).Width
lngheight = cmdbutton(0).Height
Load cmdbutton(intcount)
cmdbutton(intcount).Caption = "&" & CStr(intcount)
If cmdbutton(intcount).Left<= _
frmmain.Width - lngwidth Then
cmdbutton(intcount).Top = cmdbutton(intcount - 1).Top
cmdbutton(intcount).Left = cmdbutton(intcount- 1) _
.Left+lngwidth

Else
cmdbutton(intcount).Top = cmdbutton(intcount - 1).Top
+lngheight
cmdbutton(intcount).Left = cmdbutton(0).Left
End If
cmdbutton(intcount).Visible = True
End Sub
以上程式之if cmdbutton(intcount).Left <=frmmain.Width - lngwidth Then
一段中,为何 cmdbutton(intcount).Left 的值是固定的,有所不明?
其该段原始程式为cmdbutton(intcount-1).Left <=frmmain.Width - _
2*lngwidth Then

Follow Ups: