With用在对象前面,这样在With..End With块中就可以使用点号来引用对象的属性和方法了。 例子: Dim rst as Adodb.Recordset With rst Msgbox .field("ID") .addnew .Field("Name")="uu" .Update End With
但是这个就不成 With Picture1 .PSet (0, 0) End With
用 With 可以加快访问对象属性和方法的速度。
如果这样不成 With Picture1 .PSet (0, 0) End With 那么这样也应该不成 Picture1.PSet(0,0)吧
with 用来提高代码的 可读性,让代码看上去更漂亮:-)
我试过了 Picture1.PSet(0,0) 可以但 With Picture1 .PSet (0, 0) End With 回报告"语法错误"
执行 PSet 时,CurrentX 和 CurrentY 属性被设置为参数指定的点。想用 PSet 方法清除单一像素,规定该像素的坐标,并用 BackColor 属性设置作为 color 参数。这个方法不能用在 With匛nd With 语句块中。
Circle 执行时,CurrentX 和 CurrentY 属性被参数设置为中心点。这个方法不能用在 With匛nd With 语句块中。
with 一般是用来简化代码用的
例子:
Dim rst as Adodb.Recordset
With rst
Msgbox .field("ID")
.addnew
.Field("Name")="uu"
.Update
End With
With Picture1
.PSet (0, 0)
End With
With Picture1
.PSet (0, 0)
End With
那么这样也应该不成 Picture1.PSet(0,0)吧
Picture1.PSet(0,0)
可以但
With Picture1
.PSet (0, 0)
End With
回报告"语法错误"