求vb实例, 20
如我在TEXT1中输入“LSE”,点击“新增”后,会在如下窗体中自动增加一个“LSE”的按钮,并且“LSE”这个按钮要具有“WS”这个按钮的所有作用,有谁有这个的实例或者...
如我在TEXT1中输入“LSE”,点击“新增”后,会在如下窗体中自动增加一个“LSE”的按钮,并且“LSE”这个按钮要具有“WS”这个按钮的所有作用,有谁有这个的实例或者能帮我看看这个程序应该怎么写吗?
展开
2个回答
展开全部
给你一个增加按钮的例子吧!
Option Explicit
Private WithEvents NewButton As CommandButton
Private Sub Command1_Click()
If NewButton Is Nothing Then
Set NewButton = Controls.Add("VB.CommandButton", "cmdNew", Form1)
NewButton.Move Command1.Left + Command1.Width + 240, Command1.Top
NewButton.Caption = "动态添加的按钮"
NewButton.Visible = True
End If
End Sub
Private Sub Command2_Click()
If NewButton Is Nothing Then
Exit Sub
Else
Controls.Remove NewButton
Set NewButton = Nothing
End If
End Sub
Private Sub NewButton_click()
MsgBox "这是动态增加的按钮,你可以单击“删除控件”按钮删除它", vbDefaultButton1, "Click"
End Sub
Option Explicit
Private WithEvents NewButton As CommandButton
Private Sub Command1_Click()
If NewButton Is Nothing Then
Set NewButton = Controls.Add("VB.CommandButton", "cmdNew", Form1)
NewButton.Move Command1.Left + Command1.Width + 240, Command1.Top
NewButton.Caption = "动态添加的按钮"
NewButton.Visible = True
End If
End Sub
Private Sub Command2_Click()
If NewButton Is Nothing Then
Exit Sub
Else
Controls.Remove NewButton
Set NewButton = Nothing
End If
End Sub
Private Sub NewButton_click()
MsgBox "这是动态增加的按钮,你可以单击“删除控件”按钮删除它", vbDefaultButton1, "Click"
End Sub
展开全部
Private Sub Command1_Click(Index As Integer)
'放置一个文本框和一个按钮控件,并将按钮控制复制成数组控件,
'删除index为0之外的对象
Static CuIndex As Integer
CuIndex = CuIndex + 1
Load Command1(CuIndex)
Command1(CuIndex).Caption = Text1.Text
Command1(CuIndex).Visible = True
Command1(CuIndex).Left = Command1(CuIndex - 1).Left + Command1(0).Width + 100
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询