weixin7944 发表于 2006-7-20 09:05:00

请帮助检查一下有什么错误!

<P>有一套程序,主要功能是关闭引用背景图的相关图层的。由用户在TEXTBOX1中输入需要关闭的图层名称,几个图层之间要用;分隔。由于所有引用都有引用名称如XREF1等。如图层:XREF1│0,故关闭时需要从图层名称的后几位开始。程序如下:</P>
<P>Private Sub CommandButton1_Click()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim layname As String<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim z As Integer<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim ii As Integer<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim lay4 As AcadLayer<BR>&nbsp;&nbsp; z = 1<BR>&nbsp;&nbsp;&nbsp; For ii = 1 To Len(TextBox1.Text)<BR>&nbsp;&nbsp;&nbsp; ii = InStr(z, TextBox1.Text, Chr(59))<BR>&nbsp;&nbsp;&nbsp; If ii = 0 Then<BR>&nbsp;&nbsp;&nbsp; layname = Mid(TextBox1.Text, z, (Len(TextBox1.Text)))<BR>&nbsp;&nbsp;&nbsp; ii = Len(TextBox1.Text) + 1<BR>&nbsp;&nbsp;&nbsp; Else<BR>&nbsp;&nbsp;&nbsp; layname = Mid(TextBox1.Text, z, ii - z)<BR>&nbsp;&nbsp;&nbsp; z = ii + 1<BR>&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For Each lay4 In ThisDrawing.Layers<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If Mid(lay4.Name, 7) = layname Then<BR>&nbsp;&nbsp; lay4.LayerOn = False<BR>&nbsp; Exit For<BR>&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp; Next lay4<BR>&nbsp;&nbsp;&nbsp; Next ii<BR>End Sub</P>
<P>程序运行后有以下问题:1、图层名为单独数字的关不了,如XREF1│9;2、图层名为汉字的关不了,如XREF1│设备。</P>
<P>请高手指点,谢谢!</P>

雪山飞狐_lzh 发表于 2006-7-20 16:46:00

Sub tt()<BR>a = Split("1;2;设备;6;7", ";")<BR>For Each i In a<BR>&nbsp;&nbsp;&nbsp; ThisDrawing.Layers(i).LayerOn = False<BR>Next i<BR>End Sub<BR>

weixin7944 发表于 2006-7-20 19:36:00

谢谢!
页: [1]
查看完整版本: 请帮助检查一下有什么错误!