1.增加新按钮程序清单(增加新按钮.exe) 注意:本程序较难。 '指出下面所使用的新变量必须先声明,这样会自动纠错 Option Explicit '通过使用 WithEvents 关键字声明一个对象变量为新的命令按钮 Private WithEvents NewButton As CommandButton Private Sub cmd_add_Click() If NewButton Is Nothing Then '增加新的按钮cmdNew Set NewButton = Controls.Add("vb.commandButton", "cmdnew", Me) NewButton.Move cmd_add.Left, cmd_add.Top - 580, cmd_add.Width NewButton.Caption = "新增的按钮" NewButton.Visible = True Else MsgBox "你已经增加了新的按钮!", 0, "提示框" End If End Sub Private Sub cmd_minus_Click() If NewButton Is Nothing Then MsgBox "你没有增加新按钮!", 0, "提示框" Else Controls.Remove NewButton Set NewButton = Nothing End If End Sub Private Sub cmd_test_Click() If NewButton Is Nothing Then MsgBox "你没有增加新的按钮!", 0, "提示框" Else NewButton.Caption = "测试成功!" End If End Sub '新增控件的单击事件 Private Sub NewButton_Click() MsgBox "您选中的是动态增加的按钮", 0, "提示框" End Sub 2. 文本框之间用 TAB 键切换的程序清单(文本框切换.exe) 注意:本程序需要建立文本框组。 Private Sub Command1_Click() Unload Me End Sub '文本框内的文本反白显示 Private Sub Text1_GotFocus(Index As Integer) Text1(Index).SelStart = 0 Text1(Index).SelLength = Len(Text1(Index).Text) End Sub '设置回车与TAB 键功能相同 Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer) If KeyAscii = 13 Then KeyAscii = 0 SendKeys "{tab}" End If End Sub 3. 在不同位置插入文本的程序清单(插入文本.exe) '注意:本程序需要建立optionbutton 组,并把该组建立在frame 框中。 Private Sub Command1_Click() Text1.Text = "天津大学职教学院" Option1(0).Value = True Image1.Picture = LoadPicture("d:\11\20.jpg") Picture1.Picture = LoadPicture("d:\11\21.jpg") End Sub Private Sub Command2_Click() Unload Me End Sub Private Sub Image1_Click() Image1.Picture = Loa...