在名称为Form1的窗体上画一个名称为L1的标签,标题为“请确认”;再画两个命令按钮,名称分别为C1、C2,标
看不到你的图。你将下面的代码复制,粘贴到记事本中保存,将文件名改为Form1.frm,然后运行看看
VERSION 5.00
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "确认"
ClientHeight = 1935
ClientLeft = 45
ClientTop = 435
ClientWidth = 4680
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1935
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton C2
Cancel = -1 'True
Caption = "否"
Height = 300
Left = 3000
TabIndex = 2
Top = 1200
Width = 800
End
Begin VB.CommandButton C1
Caption = "是"
Default = -1 'True
Height = 300
Left = 840
TabIndex = 1
Top = 1200
Width = 800
End
Begin VB.Label L1
Caption = "请确认"
Height = 495
Left = 120
TabIndex = 0
Top = 120
Width = 1335
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
在名称为Form1的窗体上画1个名称为Label1,标题为"口令"的标签;画一个名称为Text1的文本框;再画三个命令
代码在线添加控件。
Dim WithEvents Text1 As TextBox
Dim WithEvents Label1 As Label
Dim WithEvents Command1 As CommandButton
'注意:这三句必须是全局声明,也就是在代码的最顶端通用的部分
Private Sub Form_Load()
Set Text1 = Me.Controls.Add("VB.TextBox", "Text1")
With Text1
.Visible = True
.Top = 0 '位置可以自己换大小也可以自己换,都不填就是默认的
.Left = 0
End With
Set Label1 = Me.Controls.Add("VB.Label", "Label1")
With Label1
.Visible = True
.Caption = "命令"
End With
Set Command1 = Me.Controls.Add("VB.CommandButton", "Command1")
With Command1
.Visible = True
.Caption = "按钮1"
End If
End Sub