⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 Visual.Basic.NET实用编程百例-47.6M.zip
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "动态创建控件"
   ClientHeight    =   3720
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5055
   LinkTopic       =   "Form1"
   ScaleHeight     =   3720
   ScaleWidth      =   5055
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton Command2 
      Caption         =   "删除控件"
      Height          =   495
      Left            =   3120
      TabIndex        =   1
      Top             =   3000
      Width           =   975
   End
   Begin VB.CommandButton Command1 
      Caption         =   "添加控件"
      Height          =   495
      Left            =   1080
      TabIndex        =   0
      Top             =   3000
      Width           =   1095
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private WithEvents NewTextBox As TextBox
Attribute NewTextBox.VB_VarHelpID = -1
'通过使用WithEvents关键字声明一个对象变量为新的命令按钮

Private Sub Command1_Click()
If NewTextBox Is Nothing Then
    Set NewTextBox = Controls.Add("VB.TextBox", "cmdNew", Form1)
    NewTextBox.Move 200, 200
     NewTextBox.Width = Form1.Width - 450
      NewTextBox.Height = Form1.Height - 1400
      NewTextBox.Visible = True
End If
End Sub

Private Sub Command2_Click()
If NewTextBox Is Nothing Then
    Exit Sub
Else
   Controls.Remove NewTextBox
   Set NewTextBox = Nothing
   End If
End Sub


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -