贾斯敏·范登博加尔德,这样怎么样??请记住,在单步执行
代码时,可以使用“局部变量”窗口来查看变量值。
ps:我不是VB'er,所以这可能不是100%
-
- Option Explicit
- '
- ' Test Routine for Demo Only.
- '
- Public Sub CLLayer()
- On Error GoTo CLLayer_Error
- Dim Ylayer As AcadLayer
- Set Ylayer = ThisDrawing.Layers.Add("Yellow")
- Dim ColorProperty As Integer
- ColorProperty = acYellow
- Ylayer.color = ColorProperty
- ' Could have used :
- ' Ylayer.color = acYellow
- ' to save the declaration and assignment
- '
- ' Next Option
- '
- Dim Glayer As AcadLayer
- Dim TrueColor As New AcadAcCmColor
- Call TrueColor.SetRGB(0, 255, 0)
- Set Glayer = ThisDrawing.Layers.Add("Green")
- Glayer.TrueColor = TrueColor
- '
- '
- ' Next Option
- '
- Dim Newlayer As AcadLayer
- Set Newlayer = ThisDrawing.Layers.Add("FourtyOne")
- Newlayer.color = 41
- '
- ' Added for fun
- '
- Dim aacColor As AcadAcCmColor
- Set aacColor = Newlayer.TrueColor
- Dim strColor As String
- strColor = "Red = " & aacColor.Red & vbCrLf & _
- "Green = " & aacColor.Green & vbCrLf & _
- "Blue = " & aacColor.Blue
- MsgBox strColor
- On Error GoTo 0
- GoTo Set_To_Nothing
- CLLayer_Error:
- MsgBox "Error " & Err.Number & " (" & Err.Description & _
- ") in procedure CLLayer of Module TestLayer"
- Set_To_Nothing:
- Set Glayer = Nothing
- Set Ylayer = Nothing
- Set Newlayer = Nothing
- Set aacColor = Nothing
- End Sub
|