VB中 With .Tables()是什么意思?

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/04 10:26:17
VB中 With .Tables()是什么意思?

VB中 With .Tables()是什么意思?
VB中 With .Tables()是什么意思?

VB中 With .Tables()是什么意思?
With 语句:对一个对象执行多个动作
我们经常需要在同一对象中执行多个不同的动作.例如,需要对同一对象设置几个属性.途径之一是使用多条语句.
Private Sub Form_Load()
Command1.Caption = "OK"
Command1.Visible = True
Command1.Top = 200
Command1.Left = 5000
Command1.Enabled = True
End Sub
应注意的是所有这些语句使用同一个对象变量 Command1要书写许多遍,非常麻烦,还不利于阅读.通过使用 With...End With 语句,可使该代码更容易编写、阅读和更有效地运行.
Private Sub Form_Load()
With Command1
.Caption = "OK"
.Visible = True
.Top = 200
.Left = 5000
.Enabled = True
End With
End Sub
这样看起来是不是好多了?使用VB的“.”提示功能,书写起来也简便多了.
还可以通过将 With...End With 语句置入另一个 With...End With 语句内实现嵌套的 With 语句.