'动态添加Text控件到SSTab各个页面上
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Dim myText() As VB.TextBox
Private Sub Command1_Click()
ReDim myText(SSTab1.Tabs - 1)
Dim i%
For i = 0 To SSTab1.Tabs - 1
SSTab1.Tab = i
Set myText(i) = Form1.Controls.Add("vb.TextBox", "txt" & i & "")
myText(i).Visible = True
myText(i).Text = "txt" & i
SetParent myText(i).hWnd, SSTab1.hWnd
myText(i).Move 350, 500, 1000, 330
Next
SSTab1.Tab = 0
End Sub
Private WithEvents NewButton As CommandButton
Private Sub Form_Load()
Set NewButton = Controls.Add("VB.CommandButton", "cmd", Me)
NewButton.Move 0, 0, 1000, 1000
NewButton.Caption = "button"
NewButton.Visible = True
End Sub
Sub newButton_Click()
MsgBox "OK"
End Sub