-1

当我运行代码时,我在 pen1 上遇到错误,说对象引用未设置为对象的实例

Dim pen1 As Pen
.
.
.
.
    Private Sub setDash()





    Select Case selectDash
        Case 1

            pen1.DashStyle = Drawing2D.DashStyle.Dash
        Case 2
            pen1.DashStyle = Drawing2D.DashStyle.Dot
        Case 3
            pen1.DashStyle = Drawing2D.DashStyle.DashDot
        Case 4
            pen1.DashStyle = Drawing2D.DashStyle.DashDotDot
        Case 5
            pen1.DashStyle = Drawing2D.DashStyle.Solid
    End Select
End Sub
4

1 回答 1

0

You have to instantiate pen1 (you have just declared it). Sample code:

pen1 = New Pen(Brushes.Black)
于 2013-09-29T08:37:20.140 回答