按钮名称改成规则的,如 btn_窗口_01 、 btn_窗口_02 这样,然后改代码
If e.sender.name.startswith("btn_窗口_") Then
Dim tab As WinForm.TabControl = e.Form.Controls("TabControl1")
Dim Name As String = e.Sender.Text '获取按钮名称
If tab.TabPages(name) Is Nothing Then
tab.TabPages.Add(name,name)
Dim pb = tab.BaseControl
Forms(Name).OPEN(-1000,-1500)
Forms(Name).BaseForm.TopLevel = False
Forms(Name).BaseForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
Forms(Name).BaseForm.Dock = System.Windows.Forms.DockStyle.Fill
PB.TabPages(name).Controls.Clear
PB.TabPages(name).Controls.add(Forms(Name).BaseForm)
End If
tab.SelectedPage = tab.TabPages(name)
End If