[求助]vba怎么不按语句顺序执行?
以下程序直接执行不可以,但如果在vbarun对话框选逐语句就可以运行.开始时我想在对话框按下一个按纽,然后在图上选一个点,插入一个块,就用了sample的程序试了一下,结果对话框是焦点的情况下不能用utility的getpoint,只能在form1.hide之后才能utility.getpoint.后来发现,ThisDrawing.SendCommand 以后对话框还在,但不是焦点,可以用utility.getpoint,所以我想在getpoint前用一个空的指令,让对话框仍然显示在屏幕上,但不是焦点.
Private Sub CommandButton2_Click()
<BR> <BR> Dim returnPnt As Variant<BR> <BR><BR> ThisDrawing.SendCommand ("_open")<BR> <BR> returnPnt = ThisDrawing.Utility.GetPoint(, "Enter a point: ")<BR> <BR> <BR> MsgBox "The WCS of the point is: " & returnPnt(0) & ", " & returnPnt(1) & ", " & returnPnt(2) & vbCrLf & _<BR> "(Enter the next value without prompting.)", , "GetPoint Example"<BR> <BR><BR> returnPnt = ThisDrawing.Utility.GetPoint<BR> MsgBox "The WCS of the point is: " & returnPnt(0) & ", " & returnPnt(1) & ", " & returnPnt(2), , "GetPoint Example"<BR> <BR><BR> Dim basePnt(0 To 2) As Double<BR> basePnt(0) = 2#: basePnt(1) = 2#: basePnt(2) = 0#<BR> returnPnt = ThisDrawing.Utility.GetPoint(basePnt, "Enter a point: ")<BR> MsgBox "The WCS of the point is: " & returnPnt(0) & ", " & returnPnt(1) & ", " & returnPnt(2)<BR> <BR><BR> Dim lineObj As AcadLine<BR> Set lineObj = ThisDrawing.ModelSpace.AddLine(basePnt, returnPnt)<BR> ZoomAll<BR> UserForm1.Show<BR> <BR>End Sub
哈哈,我也碰到过这个问题,也是插入块,一步步执行没问题,连续执行就出问题。没办法解决,后全部改为sendcommand. ThisDrawing.SendCommand ("_open")<BR>?
什么意思 ThisDrawing.SendCommand ("_open")<BR>主要是为了让焦点回到autocad,可以传入一个空的指令.
不过我发现sendcommand好象一般到最后才执行,不知道为什么? 让焦点回到autocad,用AppActivate Application.Caption<BR>
页:
[1]