获取图层名时遇到的问题 谢谢
这段程序 目的是每找到一个图层就把这个图层的名字给动态数组中的一个变量,不这道怎么了 红色的部分提示有问题,谢谢指教。同时很想知道更简单的方法,谢谢Private Sub CommandButton1_Click()<BR>Dim layerNames As String<BR>Dim entry As AcadLayer<BR>Dim layercount As Integer<BR>Dim j As Integer<BR>j = 0<BR>layerNames = ""<BR>For Each entry In ThisDrawing.Layers<BR>layerNames = layerNames + entry.Name + vbCrLf<BR>Dim layernamesarray() As String<BR>For i = j To j<BR><FONT color=#ff0000>layernamesarray(i) = entry.Name</FONT><BR>j = j + 1<BR>Next<BR>Next<BR>For i = 0 To layercount - 1<BR> MsgBox "图形中的图层有: " + vbCrLf + layernamesarray(i)<BR>Next<BR>End Sub<BR> 你的数组元素个数没有指定吧
Sub listlayer()<BR>Dim i As Integer<BR>Dim s As Integer<BR>Dim layerm() As String<BR>s = ThisDrawing.Layers.Count - 1<BR>ReDim layerm(s) As String<BR>For i = 0 To s<BR>layerm(i) = ThisDrawing.Layers.Item(i).Name<BR>Debug.Print layerm(i)<BR>Next
End Sub<BR> 太复杂了,错误又多,给你一个:Private Sub CommandButton1_Click()
Dim strLayer() As String
Dim i As Integer
ReDim strLayer(ThisDrawing.Layers.Count - 1) As String
For i = 0 To ThisDrawing.Layers.Count - 1
strLayer(i) = ThisDrawing.Layers(i).Name
MsgBox strLayer(i)
Next i
End Sub 谢谢两位老大,写出我那么烂的程序因为我根本没学过vba,呵~~
<A name=13120><FONT color=#000066><B>lzh741206</B></FONT></A>老大 写出这样的程序 你推荐教材吗,谢啦 教材?我看的是帮助,没学过什么教材 那我也看帮助去......... 程序确实构精简,非常巧妙!
妙不可言......
页:
[1]